Hi Timo, > a) Is it really THAT complicated to create an instance of MyEntity and set > the attribute? I'm coming from the Rails/ActiveRecord world where this could > easily be done with a single line of code (including saving the instantiated > object): MyEntity.new(:attribute1 => "Test").save ) > > b) How can I save this fresh instance and update my NSTableView?
After you have modeled your entity in the Xcode core data modeling view, you can use instance = NSEntityDescription.insertNewObjectForEntityForName( "MyEntity", inManagedObjectContext:managedObjectContext ) to instantiate an instance. You can save it calling error = Pointer.new_with_type("@") managedObjectContext.save(error) To save attributes, simply assign to them: instance.attribute1 = 'Test' This assumes you've added that attribute to your model. The managedObjectContext can be created or, if you're using a core data project like the document one, you'll have a managedObjectContext accessible from your NSDocument subclass: self. managedObjectContext If you have bound your NSTableView to the model object, changes will be picked up automatically. You'll only need to call save to actually persist to disk. I hope this helps somewhat, there's much more detail to it and the following links explain more of those: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html and some MacRuby specific ones that I've found useful in the past http://www.springenwerk.com/2008/10/macruby-and-core-data-tutorial.html http://cyberfox.com/blog/120-how-i-learned-to-stop-worrying-about-core-data-and-love-macruby http://reborg.tumblr.com/post/263347770/macruby-coredata-tutorial Cheers, Sven
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel