Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add standard ivars and properties to an NSManagedObject?

Can I add standard properties to an NSManagedObject. I don't expect these objects to be saved, but I would like them to persist for the lifetime that the application is running.

Can I add a getter and setter backed with an ivar?

like image 474
Undistraction Avatar asked Jun 07 '12 18:06

Undistraction


2 Answers

In this case "transient properties" are commonly used. You declare them in your Core Data Model like your other Entity properties but flag them as "transient" in the data model inspector. They are part of your Core Data model, but not persisted! enter image description here

like image 81
bijan Avatar answered Oct 31 '22 03:10

bijan


Yes, you can add your own properties and methods to a class derived from NSManagedObject. I do this all the time. You can declare the properties @dynamic (if using Core Data), or simply @synthesize them.

like image 44
melsam Avatar answered Oct 31 '22 04:10

melsam