Should @synthesize be used still?

前端 未结 4 475
一生所求
一生所求 2021-01-19 02:20

I\'m just wondering if @synthesize should still be used even though Xcode does it automatically for properties, simply because it\'s been done that way for so long? Or does

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 02:56

    I personally no longer use synthesize for new development only unless required (see lnafziger's comment below). The reason is because I currently develop for iOS 6, which requires a new version of Xcode, which has the capabilities of auto-including the @synthesize during compile time. If I were to do this with old code, there may still be someone in my organization that is using an old version of Xcode (i.e version 4.2) where this would cause problems for them.

    So depending on if you still need to be compatible with the older versions of Xcode, this answer will vary. But if you only need to work with new versions of Xcode, you should be fine not declaring @synthesize.

提交回复
热议问题