Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>So my question: What's going on here, and why? (Also, how can both of those answers be correct...?)</p> </blockquote> <p>I actually think the answer to <a href="https://stackoverflow.com/questions/11433943/why-does-objective-c-block-still-work-without-copying-it-to-the-heap">the other question</a> is wrong, in that it doesn't answer that particular question about blocks in ARC. The question is about passing a stack based block from one function/method to another. The answer is about something different, which is capturing __block variables within a block. That's a different issue.</p> <p>The answer to your question is in the FAQ of the <a href="http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html" rel="nofollow noreferrer">Transitioning to ARC Release Notes:</a></p> <blockquote> <p>Blocks “just work” when you pass blocks up the stack in ARC mode, such as in a return. You don’t have to call Block Copy any more. You still need to use [^{} copy] when passing “down” the stack into arrayWithObjects: and other methods that do a retain.</p> </blockquote> <p>So the way this works is that when you pass a block (in your case a block literal allocated on the stack), the compiler <strong>does not copy</strong> that block when it initializes the parameter for that call. The called function or method has the responsibility to copy that block itself if needed.</p> <p>Where ARC does copy blocks automatically is when you are <strong>returning</strong> a block from a function or method. In that case, the compiler knows that it <strong>must</strong> do a copy to the heap for you, and so it does.</p> <p>So your setter should be doing a block copy, even with ARC.</p> <p>I hope that helps.</p>
    singulars
    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.
 

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