attr_accessor on NSManagedObject
I subclassed a Core Data entity Recipe with PPRecipe < NSManaged object, and created accessors for the fields: class PPRecipe < NSManagedObject attr_accessor :name, :desc, :type, :imagePath, :serves end but these fields now don't save or display correct after I create objects, and restart the app for example. If I remove the :name accessor, then the name field starts appearing/working in the app again. What do I need to do to get accessors working for NSManagedObject attributes? Cheers Nic -- Dr Nic Williams iPhone and Rails consultants - http://mocra.com Fun with iPhone/Ruby/Rails/Javascript - http://drnicwilliams.com * Surf Report for iPhone - http://mocra.com/projects/surfreport/ *
I subclassed a Core Data entity Recipe with PPRecipe < NSManaged object, and created accessors for the fields:
class PPRecipe < NSManagedObject attr_accessor :name, :desc, :type, :imagePath, :serves end
but these fields now don't save or display correct after I create objects, and restart the app for example.
The generated accessors are writing to ivars instead of the CoreData store.
What do I need to do to get accessors working for NSManagedObject attributes?
I think what you really need is either: • an attr_dynamic to replicate the behavior of the @dynamic property getters in Objective-C, or, • an attr_coredata (or similar) call in HotCocoa which calls the primitive getters and setters. -Ben
participants (2)
-
Benjamin Stiglitz
-
Dr Nic Williams