Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm a tad surprised the compiler doesn't complain about a declaration mismatch. And, sure enough, it doesn't. I filed radar #13730581 to see what the compiler folks say.</p> <p>As @hypercrypt cites, ARC isn't going to retain or release the arguments to a method in the general case. One of the few cases where the performance vs. correctness sacrifice was large enough to warrant such a tradeoff. (Note that you'll see a storeStrong in the non-optimized case but no such thing in the -Os case Release build case).</p> <p>Which means you are really defending against a strong reference being created against the object by implication of the code in the method body (and, as per comments, that said strong reference isn't torn down when an <code>@throw</code> goes "over" the frame).</p> <p>There isn't much you can do about that -- if you pass <code>x</code> off to, say, <code>NSMutableArray</code>'s <code>addObject:</code> method, it'll create a strong reference.</p> <p>Thus, in the general case, there isn't really a means of preventing a strong reference to an object from being created as a side effect of variable usage. </p> <p>Specific to NSException cleanup, it isn't worth worrying about. Exceptions should be fatal and the state of the app after an exception is thrown is undefined (unless you can ensure that no system code was in any way involved with the exception, which isn't really viable).</p> <pre><code>// code tossed in main.m to play w/compiler behavior @protocol TestProtocol -(void) op:(__weak NSObject*)x; @end @interface DogBowl:NSObject &lt;TestProtocol&gt; @end @implementation DogBowl -(void) op:(NSObject*)x { } @end </code></pre>
    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