我@interface MyClass
如何在iOS中初始化整数?
定义
@property (nonatomic, assign) int currentUserNum;
@property (nonatomic, assign) BOOL isAlive;
和@implementation MyClass
@synthesize currentUserNum, isAlive;
-(id) init {
if (self = [super init]) {
self.currentUserNum = 0;
self.isAlive = YES;
}
return self;
}
self.currentUserNum = 0;
被撞坏定义-init
方法,但self.isAlive = YES;
可以工作!他们都是assign
财产。
我想知道为什么?谢谢!
在init中,为什么在调用[super init]之后没有返回self? –
对不起,我有超级方法 – why
应用程序崩溃时出现什么错误? – rmaddy