Note that there are some explanatory texts on larger screens.

plurals
  1. POChange with properties and ivars after ARC migration
    primarykey
    data
    text
    <p>I have used the "Convert to Objective C ARC" option in Xcode 4.3 to convert a project started in Xcode 4.0 to use ARC. After fixing errors that the tool found, I went trough the process where the migration tool has removed all the release messages as well as retain attributes in my properties declarations. So now I have all of my properties having only <em>(nonatomic)</em> attribute. From reading the documentation I still don't have a clear answer on what to do. </p> <p>So my question is: <em>In case you omit the keyword regarding the setter semantics (strong, weak, retain, assign) in the property declaration, what is the default attribute on properties when using ARC?</em> </p> <p>I found in the documentation that the default property attribute is <strong>assign</strong>. However, they also say that now the default attribute for <strong>ivars</strong>, in case you omit it, is <strong>strong</strong>.</p> <p>To better explain my question, here is an example. I header file we have the declaration:</p> <pre><code>@property (nonatomic) MyClass *objectToUse; </code></pre> <p>and in our implementation we just have </p> <pre><code>@synthesize objectToUse; </code></pre> <p>If we then write inside some method:</p> <pre><code>self.objectToUse = [[MyClass alloc] init]; </code></pre> <p>have we created an strong (retain) or weak (assign) reference? If we instead write</p> <pre><code>objectToUse = [[MyClass alloc] init]; </code></pre> <p>by using the ivar have we changed the situation regarding the object retention policy? It seems to me that now with ARC, the best practice of using the properties for memory management is not the same practice anymore.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload