Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would assume that when you assign new object to a reference that used to hold an object then <strong>the original object is released right away</strong> (if nothing else points to it - ref count goes to zero) using ARC and asuming default <code>strong</code> reference as in your loop example.</p> <pre><code>MyObject *object = [[MyObject alloc] init]; // obj1, ref count 1 because strong object = [[MyObject alloc] init]; // obj2, ref count of obj1 should be 0 // so obj1 gets released </code></pre> <p>Apple notes in <a href="https://developer.apple.com/library/mac/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html" rel="nofollow">Transitioning to ARC Release Notes</a></p> <blockquote> <p>Try to stop thinking about where the retain/release calls are put and think about your application algorithms instead. Think about “strong and weak” pointers in your objects, about object ownership, and about possible retain cycles.</p> </blockquote> <p>It sounds that the <code>release</code> is called on object when it's assigned new value, from clang <a href="http://clang.llvm.org/docs/AutomaticReferenceCounting.html" rel="nofollow">Clang 3.4 documentation OBJECTIVE-C AUTOMATIC REFERENCE COUNTING (ARC)</a> </p> <blockquote> <p>Assignment occurs when evaluating an assignment operator. The semantics vary based on the qualification:</p> <p>For __strong objects, the new pointee is first retained; second, the lvalue is loaded with primitive semantics; third, the new pointee is stored into the lvalue with primitive semantics; and finally, the old pointee is released. This is not performed atomically; external synchronization must be used to make this safe in the face of concurrent loads and stores.</p> </blockquote>
    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.
    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