If I keep calling this method over and over and over:
-(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;
}
…it will eventually crash. I suspect a memory leak somewhere but can’t seem to find it. Could it be here or possibly on the view it is loading? I shouldn’t need to release profiles because I don’t alloc it, right?
Hmm, I wasn’t aware that you could call
releaseby simply doingobject.release, are you sure you can do that? If not, then that would explain the crashing. Each time you call it, the view controller is not being released, so they’re just piling up, there’s your memory leak. Try changing it to[da31p2Control release].