Simple Obj-C Memory Management Question

Posted by yar on Stack Overflow See other posts from Stack Overflow or by yar
Published on 2010-05-11T20:41:59Z Indexed on 2010/05/11 20:44 UTC
Read the original article Hit count: 204

This is from some sample code from a book

// On launch, create a basic window
- (void)applicationDidFinishLaunching:(UIApplication *)application { 
 UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
 UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[HelloController alloc] init]];
 [window addSubview:nav.view];
 [window makeKeyAndVisible];
}

But a release is never called for window nor for nav.

  1. Release should be called since alloc was called, right?
  2. If #1 is right, then I would need to store a reference to each of these in an instance variable in order to release them in the dealloc?

Perhaps I'm wrong all around...

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about memory-management