Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are right, loadingStatus is being deallocated. That is because the value is being autoreleased.</p> <p>If you change</p> <pre><code>loadingStatus = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"bad", nil] forKeys:[NSArray arrayWithObjects:@"amount", nil ] ]; </code></pre> <p>to</p> <pre><code>loadingStatus = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"bad", nil] forKeys:[NSArray arrayWithObjects:@"amount", nil ] ]; [loadingStatus retain]; </code></pre> <p>or</p> <pre><code>loadingStatus = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:@"bad", nil] forKeys:[NSArray arrayWithObjects:@"amount", nil ] ]; </code></pre> <p>then your code will work.</p> <p>The reason for this is that the object that is returned from dictionaryWithObjects:forKeys has had autorelease called on it, so if you want to keep it from being deallocated, you need to call retain.</p> <p>As a reference, <strong>if you call alloc/init, you get an object with a retain count of 1. If you use a method such as dictionaryWithObjects:forKeys: you get an object with a retain count of 0</strong>. To fix that problem, just add a retain and you will be good to go.</p> <p>Apple has some really nice documentation on memory management. I recommend checking it out when you have the chance</p> <p><a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html" rel="nofollow">Memory Management Guide</a></p> <p><a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/20000994-BAJHFBGH" rel="nofollow">Memory Management Rules</a></p> <p>Hope this helps!</p> <p>-Scott</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. 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