Skip navigation.
 
mlRe: NSArrayController & NSTreeController default sort order
FROM : Chris Schmitt
DATE : Tue Jan 22 20:52:27 2008

I understand what you are saying about the objects in the controller 
not being sorted, but I am confused on why I would need a separate 
entity to have my sort order stored correctly.  If I could retrieve 
the data using that "sortOrder" attribute, why couldn't I just use any 
of the entity attributes to retrieve the sorted objects?

Also after reading the posts, I wonder if it would make more sense to 
set a default sort order on the tree's and tables that are using the 
data instead of handling it in the controller.  Is this the 
"preferred" way to show the data with a default sort order?

Thanks again for all the help.

On Jan 22, 2008, at 2:09 PM, I. Savant wrote:

> On Jan 22, 2008 2:06 PM, I. Savant <<email_removed>> wrote:

>>>> How do I set up the bindings correct
>>>> so my controllers fetch the data pre-sorted?

>>>
>>> Subclass your controller and override -arrangeObjects:.

>>
>>  Um ... or, you could use the controller's -setSortDescriptors:
>> method or its sortDescriptors binding since they're there for just
>> that purpose.

>
>  Addendum: Of course if you're using Core Data, you need to be aware
> that there's no pre-determined order in which you'll receive members
> of a fetch (which is the case with your controller). You'd need to add
> a sortable attribute to your entity like, "sortOrder" and assign each
> instance a sane value. You'd use that key when setting your
> controller's sort descriptors.
>
> --
> I.S.

Related mailsAuthorDate
mlNSArrayController & NSTreeController default sort order Chris Schmitt Jan 22, 18:17
mlRe: NSArrayController & NSTreeController default sort order Kyle Sluder Jan 22, 19:57
mlRe: NSArrayController & NSTreeController default sort order I. Savant Jan 22, 20:06
mlRe: NSArrayController & NSTreeController default sort order I. Savant Jan 22, 20:09
mlRe: NSArrayController & NSTreeController default sort order Chris Schmitt Jan 22, 20:52
mlRe: NSArrayController & NSTreeController default sort order I. Savant Jan 22, 20:57