Class CPSortDescriptor

CPObject
    extended byCPSortDescriptor

@implementation CPSortDescriptor : CPObject

A CPSortDescriptor holds the attributes necessary to describe how to sort a set of objects. The sort descriptor instance holds a property key path to the sort item of the objects to compare, the method selector to call for sorting and the sort order.


Method Summary
-(id)initWithKey:(CPString)aKey ascending:(BOOL)isAscending
          Initializes the sort descriptor.
-(id)initWithKey:(CPString)aKey ascending:(BOOL)isAscending selector:(SEL)aSelector
          Initializes the sort descriptor.
-(BOOL)ascending
          Returns YES if the sort descriptor's order is ascending.
-(CPComparisonResult)compareObject:(id)lhsObject withObject:(id)rhsObject
          Compares two objects.
-(CPString)key
          Returns the descriptor's property key.
-(id)reversedSortDescriptor
          Makes a copy of this sort descriptor with a reversed sort order.
-(SEL)selector
          Returns the selector of the method to call when comparing objects.

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass


Method Detail

initWithKey

-(id)initWithKey:(CPString)aKey ascending:(BOOL)isAscending
Initializes the sort descriptor.
Parameters:
aKey - the property key path to sort
isAscending - the sort order
Returns:
the initialized sort descriptor

initWithKey

-(id)initWithKey:(CPString)aKey ascending:(BOOL)isAscending selector:(SEL)aSelector
Initializes the sort descriptor
Parameters:
aKey - the property key path to sort
isAscending - the sort order
aSelector - this method gets called to compare objects. The method will take one argument (the object to compare against itself, and must return a CPComparisonResult.

ascending

-(BOOL)ascending
Returns YES if the sort descriptor's order is ascending.

compareObject

-(CPComparisonResult)compareObject:(id)lhsObject withObject:(id)rhsObject
Compares two objects.
Parameters:
lhsObject - the left hand side object to compre
rhsObject - the right hand side object to compare
Returns:
the comparison result

key

-(CPString)key
Returns the descriptor's property key

reversedSortDescriptor

-(id)reversedSortDescriptor
Makes a copy of this sort descriptor with a reversed sort order.
Returns:
the reversed copy of the sort descriptor

selector

-(SEL)selector
Returns the selector of the method to call when comparing objects.

Created on Sat Sep 13 14:15:43 PDT 2008