Re: Beginner Question Re: Memory Management
Re: Beginner Question Re: Memory Management
- Subject: Re: Beginner Question Re: Memory Management
- From: Ken Thomases <email@hidden>
- Date: Tue, 23 Jun 2009 00:14:20 -0500
On Jun 22, 2009, at 3:39 PM, Daniel Torrey wrote:
I'm looking at some sample iPhone code, and in the app delegate's
applicationDidFinishLaunching method, I see
// Set up the view controller
MyViewController *aViewController = [[MyViewController alloc]
initWithNibName:@"HelloWorld" bundle:[NSBundle mainBundle]];
self.myViewController = aViewController;
[aViewController release];
I'm a little confused - I see an allocation, followed by an
assignment, followed by a release. I think that the assignment is
really a call to a setter - the myViewController field is created
automagically using the @property/@synthesize syntax.
The expression "self.myViewController" is using "dot syntax".
Objective-C 2.0 dot syntax always resolves to accessor calls. It is
not a consequence of using declared properties, synthesized or not.
It works even with old-style, manually-written properties and accessors.
That said, the property declaration gives you good information about
the semantics of how the property behaves -- again, regardless of
whether it's synthesized or implemented manually. In this case, it
should tell you that the property retains what's assigned to it, which
is why the view controller is not deallocated while it's still being
used.
Cheers,
Ken
_______________________________________________
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