【发布时间】:2013-11-16 01:25:23
【问题描述】:
据我所知,从 XCode 4.4 开始,@synthesize 将自动生成属性访问器。但是刚才我已经阅读了关于NSUndoManager 的代码示例,并且在代码中它注意到@synthesize 是显式添加的。喜欢:
@interface RootViewController ()
@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@property (nonatomic, strong) NSUndoManager *undoManager;
@end
@implementation RootViewController
//Must explicitly synthesize this
@synthesize undoManager;
我现在感到困惑...我应该什么时候将@synthesize 明确添加到我的代码中?
【问题讨论】:
-
示例代码可能是旧的。基本上,除非它变成一个问题,否则使用它(例如,委托中的属性不会自动合成)
-
尝试注释掉
@sythesize。如果代码仍然有效,则没有必要。
标签: objective-c properties synthesize