7

In XCode 4.3.2, when I run the ARC conversion refactor tool, all of my property options that were "retain" are NOT being changed into "strong". Is "strong" implied now or is this just a problem with XCode 4.3.2?

Example:

Before

@property (nonatomic, retain) NSString * someString;

After

@property (nonatomic) NSString * someString;
Brad Larson
  • 168,330
  • 45
  • 388
  • 563
joseph.hainline
  • 21,512
  • 16
  • 50
  • 70
  • 1
    See earlier question: http://stackoverflow.com/questions/7796476/property-definitions-with-arc-strong-or-retain – jonkroll Apr 19 '12 at 18:57
  • 1
    `retain` is still valid AFAIK, but it does seem like it should get converted. – jscs Apr 19 '12 at 18:57
  • thanks guys, I was unclear in my question (see edits above). It's just removing the "retain" option without adding in "strong", which ends up being a compiler warning, and not running. It's doing this on all 5 of my projects. – joseph.hainline Apr 19 '12 at 19:20
  • strong is the default if the attribute is not given – Felix Apr 19 '12 at 19:22
  • 4
    @Phix: No, for properties the default is `assign`. `__strong` is the default memory qualifier for _variables_. – jscs Apr 19 '12 at 19:50
  • Whoa, it's doing _what_?! That completely changes the meaning! – jscs Apr 19 '12 at 19:51
  • Just do a replace thing (that looks like find) and replace all?.... – TheNavigat Apr 19 '12 at 19:59
  • See the answer to this question: http://stackoverflow.com/questions/8927727/objective-c-arc-strong-vs-retain-and-weak-vs-assign – Jasper Blues May 28 '12 at 07:34
  • @Josh Caswell retain is actually not valid in ARC – pasawaya Jun 04 '12 at 03:36
  • @joseph.hainline Erlend Boe's answer is correct. The output after running the tool only includes `(nonatomic)` because `strong` is the default, so the output is the same as `(nonatomic, strong)`. – pasawaya Jun 04 '12 at 03:37
  • @qegal: That's not true. `retain` on a property is accepted by Apple/LLVM 3.1, and it is explicitly listed in [Clang's ARC doc](http://clang.llvm.org/docs/AutomaticReferenceCounting.html#ownership.spelling.property). Also note that properties defaulting to `strong` is a _change_, and a big one, that occurred in 3.1. – jscs Jun 04 '12 at 03:52
  • @josh caswell Check out this – pasawaya Jun 04 '12 at 04:04
  • @qegal: What? That question is about the `release` _method_ (and, peripherally, the `retain` method), not the property ownership qualifier. – jscs Jun 04 '12 at 04:06

2 Answers2

1

"strong" is the default when using ARC (LLVM 3.1), so the new code is correct.
(before ARC, the default was "assign")
See http://clang.llvm.org/docs/AutomaticReferenceCounting.html#ownership.spelling.property

Erlend Böe
  • 301
  • 3
  • 4
0

Strong is the equivalent of the non-ARC retain. So when you shift from non-ARC to ARC XCode doesn't understand the word retain and hence removes it. Thereby causing an error or atleast a warning, as all the instance variables require atleast two properties declared.

Shyam K
  • 2,638
  • 2
  • 17
  • 24
  • Retain is not **rejected** by Xcode in that sense of the word. It will still operate. It's just that retain is now depreciated. – The Kraken Apr 28 '12 at 11:34