Re: Ordered lists WAS ADC Core Data article
Re: Ordered lists WAS ADC Core Data article
- Subject: Re: Ordered lists WAS ADC Core Data article
- From: Scott Ellsworth <email@hidden>
- Date: Sat, 9 Apr 2005 00:18:26 -0700
On Apr 8, 2005, at 10:07 PM, Todd Blanchard wrote:
The solution I typically used was to add a sequence number
attribute and sort the elements after fetching by this attribute.
There was no concept of ordered relationship (which makes me wonder
why relationships weren't implemented with NSSet rather than
NSArray). Prior to saving, I would update the sequence numbers (if
necessary).
This is exactly how I handle this in our code in the Java world. A
separate integer attribute assigned ad-hoc before commit.
An alternative I have seen used is the pk value, as those are often
assigned from monotonically increasing sequences. This can fail,
though, if the pk value assigner only guarantees unique values, not
ordered ones, so if you really want an ordered sequence matching the
ordering in a collection, do as Todd suggests, and assign it yourself
right before commit.
On a related note, we have found that users get bent out of shape
when the sequence number or id has gaps, so if you intend to display
that ordering to a user, use an attribute under your control rather
than the pk which may not be up to you to assign. IIRC, WO usually
implemented the PK as an invisible parameter, and not one that a user
should really see at all.
Scott
_______________________________________________
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