在实现文件中,所有属性都被指定为私有。
那么,它们之间的区别:你的访问者属性和实例变量有什么区别?
- MyObj.m
@interface MyObj()
@property (nonatomic, strong) NSString *name;
@end
@implementation MyObj
@synthesize name = _name;
// Some other codes to use "name" like self.name or _name
@end
2. MyObj.m
@implementation MyObj
{
NSString *_name;
}
// Some other codes to use _name
@end
可能重复[属性与实例变量](http://stackoverflow.com/questions/719788/property-vs-instance-variable),以及约800个其他问题。看到边栏---> –