Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>My advice assumes you are using Xcode 4+ and you are not using ARC, </p> <p>command+shift+B will analyse your memory management (and dead stores and such). I think you got it right. Don't worry about the retain counts so much until you get a complaint from Analyze or find leaks with Instruments. I am not sure how reliable retain counts are. I have seen comments on SO saying not to rely on them.</p> <p>You are following the rules well New, Alloc, Copy, Retain --> You will need to release this object when you are done with it.</p> <p>I am also assuming in BidView.h your property is declared as @property(nonatomic, retain) NSArray * seatsForTableCreated;</p> <p>So releasing that in the dealloc method in BidView.m is good memory management </p> <p>EDIT It works when even though you don't allocate seats for table created because. <code>self.seatsForTableCreated = ...</code> will retain whatever object you are setting there. So if you have a property with (retain) in the declaration, you can consider </p> <pre><code>self.property = object; </code></pre> <p>as setting property and retaining it. The properties were added to objective-C to reduce similar code being in every class.</p> <p>A property in .h</p> <pre><code>@property (nonatomic,retain) NSObject * property; // don't name your properties property.. </code></pre> <p>Compiler will create 2 methods for you automatically when you <code>@synthesize</code> in the .m</p> <pre><code>-(void)setProperty:(NSObject*)newP { [newP retain]; // retains the new object so it sticks around for line 3 [property release]; // releases previous property property = newP; // set the property to the object retained in line 1 // property is now same as newP and you are responsible for releasing it // -(void) dealloc is where you should release it } </code></pre> <p>// Note, the compiler may not create the exact same code as above when creating the //setProperty method. If it does, it could be subject to change.</p> <pre><code>-(NSObject*)property { return property; } </code></pre> <p>I tried to figure out why Analyze isn't catching the issue when you don't release your property, but haven't. That is confusing and I want to explore it further.</p>
 

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