小编Sup*_*hin的帖子

为什么这个发布的视图控制器在发出消息时不会导致崩溃

- (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

iphone memory-management objective-c

0
推荐指数
1
解决办法
152
查看次数

标签 统计

iphone ×1

memory-management ×1

objective-c ×1