• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CD: Creating a managed object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: CD: Creating a managed object
      • From: "I. Savant" <email@hidden>
    • Re: CD: Creating a managed object
      • From: "Marcus S. Zarra" <email@hidden>
References: 
 >CD: Creating a managed object (From: Ian Joyner <email@hidden>)
 >Re: CD: Creating a managed object (From: mmalc Crawford <email@hidden>)
 >Re: CD: Creating a managed object (From: Ian Joyner <email@hidden>)
 >Re: CD: Creating a managed object (From: mmalc Crawford <email@hidden>)

  • Prev by Date: Re: Core Data, NSPopUpButton, and "Edit..."
  • Next by Date: Re: observing dealloc
  • Previous by thread: Re: CD: Creating a managed object
  • Next by thread: Re: CD: Creating a managed object
  • Index(es):
    • Date
    • Thread