• 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: Subclassing add: of NSArraycontroller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing add: of NSArraycontroller


  • Subject: Re: Subclassing add: of NSArraycontroller
  • From: ALEXander <email@hidden>
  • Date: Thu, 23 Apr 2009 19:51:43 +0100

Yep, that's exactly what I am doing now. I also have a lot of prep work and just defined my document controller as delgate of the array controller to add objects.

Thanks, ALEXander.


On 23.04.2009, at 19:48, I. Savant wrote:

On Thu, Apr 23, 2009 at 2:31 PM, Kyle Sluder <email@hidden> wrote:
On Thu, Apr 23, 2009 at 8:17 AM, ALEXander <email@hidden> wrote:
In the renumbering routine, when I access [self arrangedobjects], or even if
I do a new fetch on my managedObjectContext, the new object is not there
yet. I tried all this:

From the documentation on -[NSArrayController add:], found at
http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSArrayController_Class/Reference/Reference.html#/ /apple_ref/doc/uid/20002042-DontLinkElementID_1
:


"Beginning with Mac OS X v10.4 the result of this method is deferred
until the next iteration of the runloop so that the error presentation
mechanism can provide feedback as a sheet."


So you can't expect that immediately after calling -add: that anything
will have changed. Maybe you can instead override -newObject.

An alternative approach is to avoid the -add: method altogether and write your own method that creates the object (and inserts it into the MOC if using Core Data) via code. This way, you know that the object is ready to go (or not ready to go) and can tell the array controller to update (or throw an error) yourself when you choose. Just make sure you're following proper KVO etiquette by wrapping the changes with -will/didChangeValueForKey: (and not "changing the array behind the controller's back").

 This is the way I handle this scenario, but admittedly, I'm doing
this with Core Data. The problem I'm solving is not only DnD and
manual sort order, but also some complicated model prep work when a
new 'record' is created (ie, each 'record' is a pretty complicated
object graph in its own right).

 Put simply, the -[NSArrayController add:] method is a convenience.
If you need control, you probably need to roll your own method.

--
I.S.

_______________________________________________

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


References: 
 >Subclassing add: of NSArraycontroller (From: ALEXander <email@hidden>)
 >Re: Subclassing add: of NSArraycontroller (From: Kyle Sluder <email@hidden>)
 >Re: Subclassing add: of NSArraycontroller (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: Subclassing add: of NSArraycontroller
  • Next by Date: Re: C numerical libraries for integrating with Cocoa
  • Previous by thread: Re: Subclassing add: of NSArraycontroller
  • Next by thread: Strange problem with NSNotificationCenter and NPAPI plugin
  • Index(es):
    • Date
    • Thread