|
Change to a qualified and sorted fetch specification
By default records are retreived in the order in which they occur in
the database table
Four sort options are available
- EOSortOrdering.CompareAscending
- EOSortOrdering.CompareDecending
- EOSortOrdering.CompareCaseInsensitiveAscending
- for Strings
- EOSortOrdering.CompareCaseInsensitiveDescending
//create a sort ordering stored in an array
NSMutableArray orderings = new NSMutableArray();
EOSortOrdering order1 = new EOSortOrdering("lastName", EOSortOrdering.CompareCaseInsensitiveAscending);
orderings.addObject(order1);
// Perform a qualified fetch and sort
//
EOFetchSpecification fetchSpec = new EOFetchSpecification("Student",
qual, orderings);
EOEditingContext ec = session().defaultEditingContext();
studentlist = (NSMutableArray)ec.objectsWithFetchSpecification(fetchSpec);
Additional sort orderings are added by adding extra orderings to the
array
While it is best to sort as the records are fetched from the database,
it can also be done in memory
NSArray sorted = EOSortOrdering.sortedArrayUsingKeyOrderArray(results,
orderings);
Sort the names that include "e" in ascending order
Lecture 3 Fetch Demo 3 (Download )
Use EOUtilities to create a fetch specification
A wrapper for common fetches (See the Java Doc for more info)
Tutorial 62 Qualifying Fetch Specifications
Page updated 10/9/02
|