Re: How to avoid excessive hard coding when programatically inserting Core Data entity ?
Re: How to avoid excessive hard coding when programatically inserting Core Data entity ?
- Subject: Re: How to avoid excessive hard coding when programatically inserting Core Data entity ?
- From: Shawn Erickson <email@hidden>
- Date: Sun, 16 Sep 2007 08:16:36 -0700
On Sep 16, 2007, at 8:01 AM, Shawn Erickson wrote:
On Sep 16, 2007, at 7:38 AM, Erik Buck wrote:
Does anyone have suggestions for how to reduce the amount of hard
coding going on ?
Not knowing exactly what you mean by hard coding in this context...
@implementation VT4ImageGraphic (VT4Utility)
+ (VT4PointVector*) pointVectorWithPoint:(NSPoint)aPoint inContext:
(NSManagedObjectContext*)
{
// Create an entity to store the position of the image
VT4PointVector *newPoint = [NSEntityDescription
insertNewObjectForEntityForName:@"VT4PointVector"
i
nManagedObjectContext:aManagedObjectContext];
[newPoint setX:[NSNumber numberWithFloat:aPoint.x]];
[newPoint setY:[NSNumber numberWithFloat:aPoint.y]];
return newPoint;
}
I should also note that since you appear to be subclassing
NSManagedObject to provide named accessors for your various objects
consider having those subclasses provide methods like the above. This
would hide the entity aspects of things from clients.
-Shawn
_______________________________________________
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