有没有办法让@property而不是@synthesize?

时间:2019-04-04 19:36:48

标签: objective-c xcode

我讨厌这样做

//in file.h    
@property (strong) NSString *reuseIdentifier;
//in file.m
@synthesize reuseIdentifier = _reuseIdentifier;

这感觉太多余了。我在名称为“ reuseIdentifier”的属性和名称为“ _reuseIdentifier”的内存块之间有概念上的区别,但是为什么xcode IDE不能独自完成工作?

我感觉自己在做家务。

1 个答案:

答案 0 :(得分:3)

自2012年Xcode 4.4起,就无需显式实现或综合Objective-C属性。请参见Xcode 4.4 section of the archived "What's New in Xcode" documentation

  

Objective-C @properties在未明确实现时默认情况下进行合成。