• 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: [More Questions ]Has anyone any experience with NSTableView and NSArrayController ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [More Questions ]Has anyone any experience with NSTableView and NSArrayController ?


  • Subject: Re: [More Questions ]Has anyone any experience with NSTableView and NSArrayController ?
  • From: Scott Anguish <email@hidden>
  • Date: Wed, 30 Nov 2005 03:10:33 -0500

wait, actually, it's the opposite

array controller offers addObjects: as well as individual insert/ delete methods. so you can insert items quickly this way too.

and, as the doc says

http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaBindings/Concepts/CntrlContent.html#//apple_ref/doc/uid/TP40002147

Note: NSArrayController and NSTreeController are optimized for these methods. As a result, using these methods can provide a performance increase over modifying the model objects directly and relying on key- value observing.


there are some caveats called out in the reference spec, specifically about adding objects with selectsInsertedObjects on... but there are workarounds mentioned


http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/ObjC_classic/Classes/NSArrayController_index.html#// apple_ref/doc/uid/20002042

also, I believe that selection is easier to maintain when inserting/ deleting through the controller.




On Nov 29, 2005, at 6:23 PM, Scott Stevenson wrote:


On Nov 29, 2005, at 3:02 PM, Alexander Hartner wrote:

What are the major differences between :

1.) [[self mutableArrayValueForKey:@"array"] addObjects:someObjects]

and

2.) [contactTableController addObject:contact];

I would image the 2nd option to be slightly quicker as it accesses / notifies the controller directly, rather then access the array via KVC. What my question really boils down to is what is wrong with the second option or is it acceptable ?

Assuming you mean the second would be called many times inside a loop, it can be much, much slower than the first option. Adding objects as a batch allows coallescing to take place.


I don't see any particular advantage in using option 2 unless you're calling it from within a subclass of NSArrayController.


- Scott

--
http://theocacao.com/


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >[More Questions ]Has anyone any experience with NSTableView and NSArrayController ? (From: Alexander Hartner <email@hidden>)
 >Re: [More Questions ]Has anyone any experience with NSTableView and NSArrayController ? (From: Scott Stevenson <email@hidden>)

  • Prev by Date: Re: Warnings that won't go away
  • Next by Date: Re: Is Apple's singleton sample code correct?
  • Previous by thread: Re: [More Questions ]Has anyone any experience with NSTableView and NSArrayController ?
  • Next by thread: NSImageView + Text
  • Index(es):
    • Date
    • Thread