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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to