[MacRuby-devel] attr_accessor on NSManagedObject

Benjamin Stiglitz ben at tanjero.com
Mon Jan 5 12:49:29 PST 2009


> 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


More information about the MacRuby-devel mailing list