After I read this chapter I wanted to try and incorporate it all using the whole MVC concept.
My problem though is, I don’t know how to get hold of the Managed Object Context from another Class.
My basic design is that I have a TableViewController Class, this is both a NSTAbleViewDataSource and a NSTableViewDelegate
and I planned on using this class to organise a variety of different entities which are located in a NSMutableArray and have them displayed nice in a View Based NSTableView.
I think I’m almost there except when I try using this method for adding my very simply note to a table I can’t seem to get the ManageObjectContext from the “Document” class, which I don’t understand as after reading the documentation that should return a MOC.
This is my method:
NSManagedObjectContext *context = [Document managedObjectContext]; <— The Error is here!!!
NSManagedObject *newNote = [NSEntityDescription
[newNote setValue:@“This is a test Note, please edit as you wish” forKey:@“note”];
NSLog(@“A Managed Note Object was made”);
NSLog(@“The Managed Note Object was added to the Stamps Array”);
NSLog(@“The TableView was reloaded to display our new added Managed Object!”);
Any pointers would be most welcome, and if I’m approaching this in a completely silly way I would love to know how I should think about doing it.