Re: NSArrayController vs. fetch
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