當我覆蓋我的項目時,我得到很多潛在的對象泄漏。當我嘗試釋放該對象時,出現錯誤'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