I'm trying to edit an object in NSMutable array declared in .h file and synthesised in .m file, but the app crashes with debug saying: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray replaceObjectAtIndex:withObject:]: mutating method sent to immutable object'
The line that makes the app crash is:
[noteContent replaceObjectAtIndex:currentNote withObject:noteText.text];
noteContent is declared in .h @property (nonatomic, strong) NSMutableArray* noteContent;, synthesised in .m @synthesize noteContent and initialized in viewDidLoad
noteContent = [[NSMutableArray alloc] init];
noteContent = [standardUserDefaults objectForKey:@"noteContent"];
The problem isn't in replacing nil object, because I checked that at the position, an actual string is stored.
Thank you for your effort.