我创建了一个类,将保存用户和设备的信息。该类称为Account
。 这里是类代码(ARC项目):着用来初始化自定义类
#import <Foundation/Foundation.h>
@interface Account : NSObject
@property(strong, nonatomic) NSString *deviceID;
@property(strong, nonatomic) NSString *accountID;
@property(strong, nonatomic) NSString *oAuthCode;
@property(strong, nonatomic) NSString *type;
@property(strong, nonatomic) NSString *deviceToken;
@property(strong, nonatomic) NSString *os;
@property(strong, nonatomic) NSString *deviceName;
@end
#import "Account.h"
@implementation Account
@synthesize deviceID = _deviceID;
@synthesize deviceName = _deviceName;
@synthesize deviceToken = _deviceToken;
@synthesize type = _type;
@synthesize oAuthCode = _oAuthCode;
@synthesize accountID = _accountID;
@synthesize os = _os;
-(NSString*)deviceID{
return [ThinkerBell_OpenUDID value];
}
-(NSString*)deviceToken{
return [[NSUserDefaults standardUserDefaults]valueForKey:K_DEVICE_TOKEN];
}
-(NSString*)os{
return [[UIDevice currentDevice]systemVersion];
}
-(NSString*)deviceName{
return [[UIDevice currentDevice]model];
}
@end
我在这里创建一个实例,并试图访问他的属性:
_ac = [[Account alloc]init];
_ac.accountID = @"[email protected]";
_ac.type = @"[email protected]";
_ac.oAuthCode = @"[email protected]";
_ac.deviceName = @"[email protected]";
_ac.deviceToken = @"[email protected]";
_ac.deviceID = @"[email protected]";
_ac.os = @"[email protected]";
比我通过这个对象作为参数的方法:
[self appendAccount:_ac];
当我试图读取Account
例如他的字段。
-(void)appendAccount:(Account*)account{
NSLog(@"%@",account);
}
有什么想法吗?
请澄清你认为此代码的作用... – Eiko