App converted to ARC, now getting warnings about my properties

前端 未结 3 958
野趣味
野趣味 2021-02-07 09:12

I just converted my app to ARC, and while it builds fine, I get like 600 warnings, all pertaining to my properties. Such as:

Default propert

相关标签:
3条回答
  • 2021-02-07 09:14

    ARC is right. You cannot have no memory-management qualifer; you must say assign, retain (or strong which is the same thing), or weak.

    Previously, assign was the default. But that is probably not what you want, because is it is the worst possible option - it is an old-style non-ARC weak reference. You either want a smart ARC weak reference (goes to nil when the object goes out of existence) or a strong reference (memory-managed for you by ARC).

    0 讨论(0)
  • 2021-02-07 09:37

    Sorry to add a second answer, but this turns out to be more intricate than I thought. It turns out that you're seeing a changed behavior (perhaps a bug?) in Xcode 4.3.

    In Xcode 4.2, the converter would have offered to change (nonatomic, retain) to (nonatomic, strong). But in Xcode 4.3, it offers to change it to (nonatomic); I guess if you don't want that, changing retain to strong is up to you before converting.

    On the other hand, in Xcode 4.2, (nonatomic) alone was absolutely illegal for a synthesized property; in Xcode 4.3, it is not: you get a warning, but it assumes you mean assign and so it isn't illegal.

    So there's been a change in how ARC works in LLVM 3.1 and an accompanying change in the Xcode 4.3 ARC converter.

    0 讨论(0)
  • 2021-02-07 09:39

    I think the answers are wrong.

    In Xcode 4.3 you get a warning. However, it assumes you mean RETAIN. Retain is the new default for codes under ARC. Someone told me that xcode is fixing this.

    Please correct me if I am wrong.

    0 讨论(0)
提交回复
热议问题