- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create the navigation and view controllers
RootViewController *rootViewController = [[RootViewController alloc]
initWithStyle:UITableViewStylePlain];
UINavigationController *aNavigationController = [[UINavigationController alloc]
initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;
[aNavigationController release];
[rootViewController release];
[rootViewController setRegions:[Region knownRegions]];
// Configure and display the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
Run Code Online (Sandbox Code Playgroud)
这里,在上面的代码中,引用'rootViewController'用于发送消息'setRegions:',即使在上一行中释放了对象之后也是如此.
如果它是错的那么模拟器如何运行而没有任何崩溃?或者如果它是正确的,又如何?,我看不出自动释放和释放之间的区别.
消息来源: - http://developer.apple.com/iphone/library/samplecode/TableViewSuite/listing12.html
下载: - developer.apple.com/iphone/library/samplecode/TableViewSuite/index.html