当我对我的项目进行任何操作时,我得到了很多潜在的对象泄漏。当我尝试释放该对象时,我得到错误'someobject send to deallocated instance'
我无法理解在哪里完美地释放对象。我需要支持ios 4.3以上的版本。通过google发现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];
optionview.title=@"Options";
LogOut *logout=[[LogOut alloc]initWithNibName:@"LogOut~iPad" bundle:nil]; // method retains objective-c object with +1 retain count
logout.title=@"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
错误之后
我无法理解何时释放对象。