如果我一遍又一遍地调用这种方法:
-(IBAction)pressedNextPage {
NSUserDefaults *profiles = [NSUserDefaults standardUserDefaults];
NSInteger newUser = [profiles integerForKey:@"activeuser"];
if(newUser == 1) {
[profiles setObject:name.text forKey:@"name1"];
[profiles setObject:social.text forKey:@"social1"];
} else if(newUser == 2) {
[profiles setObject:name.text forKey:@"name2"];
[profiles setObject:social.text forKey:@"social2"];
} else if(newUser == 3) {
[profiles setObject:name.text forKey:@"name3"];
[profiles setObject:social.text forKey:@"social3"];
}
[profiles synchronize];
DA31P2ViewController *da31p2Control = [[DA31P2ViewController alloc]initWithNibName:@"DA31P2ViewController" bundle:nil];
[self.navigationController pushViewController:da31p2Control animated:YES];
da31p2Control.release;
}
......它最终会崩溃。我怀疑某处有内存泄漏,但似乎无法找到它。它可能在这里或可能在它正在加载的视图上?我不需要发布配置文件,因为我没有分配它,对吧?
答案 0 :(得分:0)
嗯,我不知道你可以通过简单地release
致电object.release
,你确定能做到吗?如果没有,那么这将解释崩溃。每次调用它时,视图控制器都没有被释放,因此它们只是堆积起来,存在内存泄漏。尝试将其更改为[da31p2Control release]
。