I have created an NSArray which I have initialized to contain the attributes of a core data entity. When I later try to set these attributes through the Array I get the error “!Expression is not assignable”. How do I set the values of the attributes by referencing them through the NSArray? Here are the relevant portions of my code:
headingArray = [[NSArray alloc] initWithObjects:
heading1,
heading2,
heading3, ...
heading1, heading2, … are attributes of the core data entity
for (int i=1; [note.headingCount intValue]-1; i++) {
[note.headingArray objectAtIndex:i] = selectedTemplateForNote.heading1;
}
the [note.headingArray objectAtIndex:i] is the code that is flagged with the error “!Expression is not assignable”.
NSArrayare immutable. You can not change their content without constructing a new array. Try using anNSMutableArrayand- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;instead.Editing based on new info:
You are probably trying to do the following then: