Re: CoreData mapping two different objects to same entity?
Re: CoreData mapping two different objects to same entity?
- Subject: Re: CoreData mapping two different objects to same entity?
- From: Kyle Sluder <email@hidden>
- Date: Sun, 15 May 2011 20:51:36 -0700
On Sun, May 15, 2011 at 6:01 PM, William Squires <email@hidden> wrote:
> Is it possible to map two different objects (the ivars are the same, just some validation methods are different) to the same entity?
You mean "same managed object," not "same entity." Which, when you use
the correct terminology, makes it more clear why this is impossible.
>
> Here's what I have:
>
> I want to make a view in which the player 'rolls up' a new player-character. This object has certain ivars (and @property declarations) that map to the entity in the .xcdatamodel file. The actual accessors, however, are hand-coded to allow certain restrictions to be relaxed while the PC is being created. Another object will also have the same (name and number) of ivars and also map to the entity, but it's accessors have more restrictions as to what can be written to. Example:
>
> @property (readwrite, assign, nonatomic) UInt32 hitPoints;
> @property (readwrite, assign, nonatomic) UInt32 maxHitPoints;
>
> in the object used in the 'roll-up-the-new-PC-window' view, but is:
>
> @property (readwrite, assign, nonatomic) UInt32 hitPoints;
> @property (readonly, nonatomic) UInt32 maxHitPoints;
I think there's a far easier way to deal with this:
@property (readwrite, assign, nonatomic) BOOL isReadOnly;
- (void)setMaxHitPoints:(UInt32)maxHitPoints {
assert(!self.isReadOnly);
// carry on
}
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden