Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think it is drawing your attention to the fact that a <code>assign</code> is being used, as opposed to <code>retain</code> or <code>copy</code>. Since an <code>NSString</code> is an object, in a reference-counted environment (ie without Garbage Collection) this can be potentially "dangerous" (unless it is intentional by design).</p> <p>However, the difference between <code>assign</code>, <code>retain</code> and <code>copy</code> are as follows:</p> <ul> <li><p><strong>assign</strong>: In your setter method for the property, there is a simple assignment of your instance variable to the new value, eg:</p> <pre><code>- (void)setString:(NSString*)newString { string = newString; } </code></pre> <p>This can cause problems since Objective-C objects use reference counting, and therefore by not retaining the object, there is a chance that the string could be deallocated whilst you are still using it.</p></li> <li><p><strong>retain</strong>: this <em>retains</em> the new value in your setter method. For example:</p> <pre><code>- (void)setString:(NSString*)newString { [newString retain]; [string release]; string = newString; } </code></pre> <p>This is safer, since you explicitly state that you want to maintain a reference of the object, and you must release it before it will be deallocated.</p></li> <li><p><strong>copy</strong>: this makes a copy of the string in your setter method:</p> <pre><code>- (void)setString:(NSString*)newString { if(string!=newString) { [string release]; string = [newString copy]; } } </code></pre> <p>This is often used with strings, since making a copy of the original object ensures that it is not changed whilst you are using it.</p></li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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