假设以下所有代码都写在一个实现文件中。有人可以解释一下两者之间的区别:
#1
@interface ViewController ()
@property (nonatomic) NSDictionary *currentAlbumData;
@end
@implementation ViewController
#2
@interface ViewController () {
NSDictionary *currentAlbumData;
}
@end
@implementation ViewController
#3
@interface ViewController
@end
@implementation ViewController {
NSDictionary *currentAlbumData;
}
- some methods here -
@end
在我看来,第一个在类扩展中声明了一个属性变量。第二个在类扩展中声明一个实例变量。第三个声明了一个不是类扩展的实例变量……这意味着什么?它与在类扩展中简单地声明 ivar 相比如何?