Re: Best practice for Core Data "ordered" NSArray problem?
Re: Best practice for Core Data "ordered" NSArray problem?
- Subject: Re: Best practice for Core Data "ordered" NSArray problem?
- From: Scott Thompson <email@hidden>
- Date: Fri, 28 Sep 2007 08:40:19 -0500
On Sep 28, 2007, at 8:31 AM, Frank Reiff wrote:
Sorry to everybody who is sick of this question.. I know it's been
asked before but I'm wondering whether there's any news on this
subject..
Core Data uses a relational database back-end, relational databases
do not have a "natural" order, therefore the results returned by a
query are unsorted unless you use a sorting descriptor. Creating an
actual array (you now where things are in sequence irrespective of
an external sorting order) thus means adding an index to the model,
which makes life difficult for NSArrayController and demands lots of
custom coding, etc..
I asked this same question through another source at Apple not too
long ago.
As this is a very common problem, I assume that there are now some
mature solutions out there to deal with this generically?
Actually this is probably not the case. The difficulty (as I
understand it) is that while there are many, many people who want to
have ordered collections in their databases, each program has subtle
differences in it's requirements that make this a difficult problem to
solve in a generic fashion. For example, my application likes to
order small groups of objects (say 20 at the most) while another
program might need to order 100,000 objects. Each of these two
applications might use a different strategy.
Something I don't know yet is whether this problem is specific to
using the SQLite store. If I use an xml store or an in-memory store
is the order guaranteed to be preserved?
You're thinking about this the wrong way, in my opinion. The idea is
that a Core Data object graph does not have an intrinsic mechanism for
managing ordered collections of objects in Tiger. How that object
graph is stored is completely irrelevant. In other words, it doesn't
matter if the store is SQLite, XML, in-memory, or recorded on papyrus
by trained squirrels. The fact that that you have to provide your own
ordering mechanism doesn't change.
Scott
_______________________________________________
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