Re: CD: Creating a managed object
Re: CD: Creating a managed object
- Subject: Re: CD: Creating a managed object
- From: Ian Joyner <email@hidden>
- Date: Tue, 29 May 2007 13:42:10 +1000
On 29/05/2007, at 8:57 AM, mmalc Crawford wrote:
On May 28, 2007, at 3:03 AM, Ian Joyner wrote:
I'm still curious as to whether this is the best way to do this
(creating an NSManagedObject in a view) or if there is a more
subtle way to set it up with bindings? I'm sure this must be a
common thing to do, but haven't seen it in any sample code.
It's not clear why bindings are relevant to object creation?
What would your architecture be if you weren't using Core Data?
Why can you not just use the array controller to create a new object?
OK, even if this is not quite right, it's only a small routine to
refactor, so I think this is pretty clean (the only thing I'm uneasy
about is manipulating a model object in a view, but perhaps that is
alright.
IBOutlet NSArrayController *nsa;
...
-(void) mouseDown: (NSEvent *)event {
NSPoint p = [event locationInWindow];
NSManagedObject *mo = [nsa newObject];
[mo setValue: [NSNumber numberWithFloat: p.x] forKey: @"x"];
[mo setValue: [NSNumber numberWithFloat: p.y] forKey: @"y"];
}
Even though I had to write some code (whereas a lot in Cocoa happens
without any code), this seems pretty minimalist for something I can't
think of doing another way.
Thanks
Ian
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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