• 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: NSArrayController vs. fetch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArrayController vs. fetch


  • Subject: Re: NSArrayController vs. fetch
  • From: mmalc crawford <email@hidden>
  • Date: Fri, 6 Oct 2006 09:12:47 -0700


On Oct 6, 2006, at 4:22 AM, Matteo Rossi wrote:

I'm displaying a list of entities in a tableview. I have an outlet to their NSArrayController in my document. If I want to perform some operations on them which is the best choice for retrieving the associated NSArray between
array=[myArrayController arrangedObjects];
and the execution of a fetch request as:
[request setEntity:[NSEntityDescription entityForName:@"myEntity" inManagedObjectContext:moc]];
array=[moc executeFetchRequest:request error:error];
I think the second one is surely updated since synchronizes with the persistent store, while the first might lead to some problems.
Again, is the first approach considered a poor or even wrong implementation ? Which is the fastest, anyway ?


If you want to perform an operation on the content of a table view provided by an array controller, then use -arrangedObjects -- that's what it's there for... If you perform a fetch, then you may get back a different result set (notably if the content of the array controller is filtered) and the ordering may be different (in some situations this might be important to you). Moreover, the fetch incurs a round trip to the persistent store, whereas the value of arrangedObjects may be cached.

mmalc

_______________________________________________
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


  • Follow-Ups:
    • Re: NSArrayController vs. fetch
      • From: Matteo Rossi <email@hidden>
References: 
 >NSArrayController vs. fetch (From: Matteo Rossi <email@hidden>)

  • Prev by Date: [Moderator] EOT Re: developing for OS-X
  • Next by Date: Re: Hit-testing in custom NSCell in NSTableview
  • Previous by thread: NSArrayController vs. fetch
  • Next by thread: Re: NSArrayController vs. fetch
  • Index(es):
    • Date
    • Thread