Adding ivars to NSManagedObject subclass

Posted by The Crazy Chimp on Stack Overflow See other posts from Stack Overflow or by The Crazy Chimp
Published on 2012-11-19T10:14:23Z Indexed on 2012/11/19 11:04 UTC
Read the original article Hit count: 286

When I create an entity using core data then generate a subclass of NSManagedObject from it I get the following output (in the .h):

@class Foo;

@interface Foo : NSManagedObject

@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSSet *otherValues;

@end

However, in my .m file I want to make use of the name and otherValues values. Normally I would simply create a couple of ivars and then add the properties for them as I required. That way I can access them in my .m file easily.

In this situation would it be acceptable to do this? Would adding ivars to the .h (for name and otherValues) cause any unusual behaviour in the persistance & retrieval of objects?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about ios