One Quickie


Sorting results (Core Data->General)
Want data to be sorted in tableviews and whatnot? You can set the "sortDescriptors" binding on an array controller. Write a method that returns the sort descriptors you want:
- (void) setWhenSortDescriptors: (NSArray *) descriptors
{
} // setWhenSortDescriptors


- (NSArray *) whenSortDescriptors
{
    NSSortDescriptor *sorter;
    sorter = [[[NSSortDescriptor alloc]
                  initWithKey: @"when"
                  ascending: NO] autorelease];

    return ([NSArray arrayWithObject: sorter]);

} // whenSortDescriptors
This is for a 'permanent' sorting, not allowing the user to change the sorting. Also, new/changed objects added to the collection don't appear to be placed in sorted order.



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com