Re: release and reference counting query
Re: release and reference counting query
- Subject: Re: release and reference counting query
- From: Filip van der Meeren <email@hidden>
- Date: Fri, 7 Nov 2008 13:03:31 +0100
I am not sure, but I am guessing the class that self refers to,
defined viewController as a property that retains the object assigned
to it.
Remember, there is a difference between "self->" and "self.".
The -> refers to the variables of the object, and "." refers to the
properties.
On 07 Nov 2008, at 12:59, Calum Robertson wrote:
Hi,
Below is a snippet of code from the "Creating an iPhone Application"
document from the iPhone DevCenter. I'm not clear as to why this
works. My understanding is that when [UIViewController alloc] is
executed, the retain count is 1 and then when [aViewController
release] is called, the retain count reduces to zero. Does
self.viewController not then reference deallocated memory? I thought
I had got the hang of retain / release but this snippet confused me...
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
// Set up the view controller
UIViewController *aViewController = [[UIViewController alloc]
initWithNibName:@"MoveMeView" bundle:[NSBundle
mainBundle]];
self.viewController = aViewController;
[aViewController release];
// Add the view controller's view as a subview of the window
UIView *controllersView = [viewController view];
[window addSubview:controllersView];
[window makeKeyAndVisible];
}
C
_______________________________________________
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
Filip van der Meeren
http://www.sourceforge.net/projects/xlinterpreter
_______________________________________________
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