Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSManagedObject; keep or load into a custom NSObject?

I'm using Core Data to store objects. I have a NSManagedObject Person and a NSObject Person. They both have the same attributes. The NSObject has some methods.

Right now, I search Core Data for Bob. I then take that NSManagedObject Bob and copy all the attributes to the NSObject Bob and do what I need with it.

Does this make sense or should I create the needed methods in the NSManagedObject instead? Can a NSManagedObject be treated the same as a NSObject?

like image 901
Padin215 Avatar asked Feb 17 '23 04:02

Padin215


1 Answers

An encouraged way is to build a category of your NSManagedObject subclass and implement your custom methods in this category. That way you can re-create your NSManagedObject subclass through Xcode if your schema changes and your category remains intact and unaffected.

Reference: e.g. Paul Hegarty's / Stanfords iOS courses on core data

like image 65
Mario Avatar answered Feb 20 '23 01:02

Mario