当我覆盖我的项目时,我得到很多潜在的对象泄漏。当我尝试释放该对象时,出现错误'someobject发送到释放实例'释放分配的对象(方法保留具有+1保留计数的objective-c对象)
我无法理解在哪里完美释放对象。 我需要支持上述的iOS 4.3 .Gone通过谷歌的版本,发现ARC从IOS 5
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
ViewController *searchController=[[ViewController alloc]initWithNibName:@"ViewController_iPad" bundle:nil];
OptionsViewController *optionview=[[OptionsViewController alloc]initWithNibName:@"OptionsViewController~iPad" bundle:nil];
[email protected]"Options";
LogOut *logout=[[LogOut alloc]initWithNibName:@"LogOut~iPad" bundle:nil]; // method retains objective-c object with +1 retain count
[email protected]"Sign Out";
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:searchController, optionview,logout, nil]; //Object leaked:object allocated and stored into logout is not referenced later in this execution path and has a retain count of +1
[self.window addSubview:tabBarController1.view]; [self.window makeKeyAndVisible];
CGRect rect = [[UIScreen mainScreen] bounds];
[self.window setFrame:rect];
return YES;
}
当我写
[self.tabBarController release];
[searchController release];
[optionview release];
[logout release];
后
[self.window setFrame:rect];
我得到Bad Excess
启用错误
我无法理解何时释放对象。
这也不正确。请参阅我的回答 – 2013-05-11 07:23:15