I've a document-based application powered by Core Data with an in-memory store. I have a table backed by an NSArrayController that is suppose to list all model objects of type Buffer. My UI also includes an NSTextView that fetches data from the the currently selected Buffer object.
I try to populate the text view thus (I'm using Fragaria):
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
if ([aNotification object] == editorList) {
Buffer *buffer = [[editorListArrayController selectedObjects] objectAtIndex:0];
[fragaria setString:[buffer valueForKey:@"content"]];
}
}
Now, whenever the user types something into the text view, I save that into the currently selected buffer and then save the changes to the managed object context:
- (void)textDidChange:(NSNotification *)notification
{
Buffer *buffer = [[editorListArrayController selectedObjects] objectAtIndex:0];
[buffer setValue:[fragaria string] forKey:@"content"];
[[self managedObjectContext] saveChanges];
[self setEditedFlagForModelAndWindow:YES];
}
My problem is that when I list all the model objects in my NSArrayController they all seem to have the same value for @"content", meaning that the same value is somehow being written to all model objects. How can I debug this?