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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/filip%40code2develop.com

This email sent to [EMAIL PROTECTED]

Filip van der Meeren
http://www.sourceforge.net/projects/xlinterpreter



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to