Re: Yet another memory management question
Re: Yet another memory management question
- Subject: Re: Yet another memory management question
- From: mmalc Crawford <email@hidden>
- Date: Sat, 04 Jul 2009 21:37:49 -0700
On Jul 4, 2009, at 9:31 PM, DKJ wrote:
On 4-Jul-09, at 21:10 , mmalc Crawford wrote:
you should use accessor methods rather than direct variable
manipulation
Would declaring all the variables as properties, and then
synthesising them, take care of this?
Strictly, this is an orthogonal issue.
Declaring and synthesising properties creates the accessor methods;
you still have to invoke them when appropriate.
If so, what should I do in dealloc for those variables?
For example, suppose I've got this in the header:
NSArray *myArray;
...
@property(retain) NSArray *myArray;
And this in the implementation file:
@synthesize myArray;
Should dealloc have this:
[myArray release];
or something like this:
self.myArray = nil;
In an initaliser method and in dealloc, you should typically set or
release the variable directly, so in dealloc it would be
[myArray release];
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden