> On Apr 28, 2016, at 10:56 AM, Daryle Walker <[email protected]> wrote:
>
> Can I use a CD model object without managed contexts nor persistent stores?
I’m pretty sure you can’t, but if you’re not doing anything fancy in your
modeling, the classes will just be pretty vanilla classes with some properties.
So you can start out declaring the model classes like
@interface Message : NSObject <NSCoding>
@property NSString* subject;
@property Address* sender;
…
and implement the NSCoding methods to save and restore the persistent
properties. Then you can save your “database” by archiving a root object that
all your models are transitively reachable from, and reload the database by
loading that archive.
When you move to Core Data, just change the declaration to
@interface Message : NSManagedObject
and in the implementation file take out the -initWithCoder: and
-encodeWithCoder: methods. You’ll also need to add an “@dynamic” declaration
for the persistent properties, so that NSManagedObject can bind them to the
database.
—Jens
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]