我的根视图控制器的释放方法被调用了38次,但我没有调用释放,为什么会发生?
@implementation AppDelegate
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
} else {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
@interface ViewController ()
@end
@implementation ViewController
-(oneway void)release
{
NSLog(@"release called");
[super release];
}
@end
输出
2013-04-09 19:47:36.060 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.063 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.064 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.065 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.065 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.066 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.067 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.068 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.072 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.073 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.074 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.075 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.077 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.080 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.081 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.081 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.082 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.108 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.110 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.111 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.112 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.134 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.144 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.158 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.161 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.170 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.180 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.182 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.193 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.197 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.198 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.199 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.202 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.208 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.208 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.218 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.220 TesteRelease[44985:c07] release called
2013-04-09 19:47:36.220 TesteRelease[44985:c07] release called
我没有使用ARC。