我在我的类中有一个NSInteger,像这样:
在@interface中:
NSInteger currentRow;
@property (assign) NSInteger currentRow;
在 @implementation 中:@synthesize currentRow;
执行[self setCurrentRow:0]
似乎运行正常,但是使用[self currentRow]
返回null,不确定原因。使用断点时,可以看到currentRow
的值为0
,所以已经成功设置,但我无法检索该值。
[self setCurrentRow:42]
,然后您会发现[self currentRow]
返回42,只需确保将结果分配给NSInteger而不是对象即可。 - secondcitysaint