When I use this method first time it works fine, but when I called it second time I get the error \"mutating method sent to immutable object\". The problem is at line with \"add
This should work:
-(IBAction) save: (id) sender {
NSMutableArray *placesT= [[NSMutableArray alloc]initWithArray:[[NSUserDefaults standardUserDefaults]
objectForKey:@"placesT"]];
if (!placesT) { placesT=[[[NSMutableArray alloc] init] autorelease]; } [placesT addObject: [NSString stringWithFormat:@"%@", tagF.text] ]; NSUserDefaults *tUD=[NSUserDefaults standardUserDefaults]; [tUD setObject:placesT forKey:@"placesT"]; [tUD synchronize]; [self dismissModalViewControllerAnimated:YES]; }