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: "I. Savant" <email@hidden>
- Date: Fri, 28 Sep 2007 13:56:51 -0400
> 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'm not sure I agree with this assessment. Whether or not you have
an "index" attribute in your model doesn't really make anything more
"difficult" for an NSArrayController than not using Core Data at all.
In either case, you set the sort descriptor and you're done (for
simple retrieval / display).
The controller layer's job is to apply the logic when drag and drop
reordering occurs, which takes exactly as much work for a Core Data
app as a non-Core Data app with Bindings. There are several very
well-written examples on the web of how to accomplish this with a
table view. It's a bit obtuse with an outline view and
NSTreeController, granted, but you don't appear to be using either.
The bottom line is, the clearest route is a "sortOrder" attribute
and some (relatively basic) custom controller code and, speaking from
experience, it works perfectly.
--
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