我正在开发一个项目,需要从服务器向支持Android和iOS的客户端发送消息.目前我在使用Android和iOS客户端的C#服务器应用程序中使用SignalR.一切都很好.但我正在寻找一些可能更好的替代方案.
我也做了一些研究,发现了一些例子,但不符合我的需要.
我正在尝试在objective-c中创建一个枚举类.以下是我已经得到的.
#import <Foundation/Foundation.h>
typedef enum {
Car,
Bike,
Boat
} Vehicle;
@interface ModelVehicle : NSObject {
Vehicle vehicle;
}
@property (nonatomic) Vehicle vehicle;
@end
Run Code Online (Sandbox Code Playgroud)
现在我可以从另一个类访问枚举,但只能使用以下代码.为什么我不能使用存在枚举的类名来访问它,例如ModelVehicle.Car?
Vehicle *hi = Car;
Run Code Online (Sandbox Code Playgroud) 我尝试更改读取并从UILabel更改位置.这个UILabel是在Interface Builder中创建的,现在我想在MainVieController类中调用一个方法时读取并更改另一个类中的位置.
但我怎么能这样做,我已经阅读了几个论坛,但我不能让它工作.这里还有一些示例代码.我希望有人可以帮助我.
MainViewController.h
#import <UIKit/UIKit.h>
@class NewClass;
@interface MainViewController : UIViewController {
UILabel *daLabel;
}
@property (nonatomic, retain) IBOutlet UILabel *daLabel;
@end
Run Code Online (Sandbox Code Playgroud)
MainViewController.m
#import "MainViewController.h"
#import "NewClass.h"
@implementation MainViewController
@synthesize daLabel;
- (void)viewDidLoad {
[super viewDidLoad];
NewClass *anotherClass = [[NewClass alloc] init];
[anotherClass test];
}
@end
Run Code Online (Sandbox Code Playgroud)
NewClass.h
#import <Foundation/Foundation.h>
@class MainViewController;
@interface NewClass : NSObject {
}
@end
Run Code Online (Sandbox Code Playgroud)
NewClass.m
#import "NewClass.h"
#import "MainViewController.h"
@implementation NewClass
- (void)test {
MainViewController *MainController = [[MainViewController alloc] init];
CGRect labelPosition = MainController.daLabel.frame;
NSLog(@"POSITION: …Run Code Online (Sandbox Code Playgroud)