I’m new to Cocoa and xCode, but not programming though.
I have created some some core data and a interface in the interface builder.
Now i need to edit and get some core data from my code. In fact I need to be able to get an “imagepath” to show a picture and to set a new value in the “imagepath”.
“imapepath” is a core data attribute.
I have figured out how to insert a new entry, but i want to edit values instead.
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *places = [NSEntityDescription
insertNewObjectForEntityForName:@"Place"
inManagedObjectContext:context];
[places setValue:[tvarNSOpenPanelObj filename] forKey:@"imagepath"];
I hope you guys have some clues 😉
If you have loaded your NSManagedObject from CoreData, then you can edit it’s values just like any other object. This is stored in your NSManagedObjectContext (ie. just in memory).
You then need to persist this to your backing store at some point, so you need to call save: on your NSManagedObjectContext – and voila, it’s saved.
You should read the programming guide for core data:
http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/coredata/cdProgrammingGuide.html#//apple_ref/doc/uid/TP30001200-SW1
(If you don’t know how to load an object from Core Data, read the section on ‘Fetching Managed Objects’, and then ‘Using Managed Objects’ to know how to edit them)…. in fact, read it all from the beginning to the end. Its invaluable for knowing how to use CoreData correctly and effectively.