40 + (id)sortDescriptorWithKey:(
CPString)aKey ascending:(BOOL)isAscending
52 - (id)initWithKey:(
CPString)aKey ascending:(BOOL)isAscending
57 + (id)sortDescriptorWithKey:(
CPString)aKey ascending:(BOOL)isAscending selector:(
SEL)aSelector
69 - (id)initWithKey:(
CPString)aKey ascending:(BOOL)isAscending selector:(
SEL)aSelector
76 _ascending = isAscending;
77 _selector = aSelector;
115 - (CPComparisonResult)compareObject:(
id)lhsObject withObject:(
id)rhsObject
117 return (_ascending ? 1 : -1) * [[lhsObject valueForKeyPath:_key] performSelector:_selector withObject:[rhsObject valueForKeyPath:_key]];
124 - (id)reversedSortDescriptor
126 return [[[
self class] alloc] initWithKey:_key ascending:!_ascending selector:_selector];
132 [
self key], [
self ascending] ? @"ascending": @"descending", CPStringFromSelector([
self selector])];
145 if (
self = [super
init])
147 _key = [aCoder decodeObjectForKey:CPSortDescriptorKeyKey];
148 _ascending = [aCoder decodeBoolForKey:CPSortDescriptorAscendingKey];
157 [aCoder encodeObject:_key forKey:CPSortDescriptorKeyKey];
158 [aCoder encodeBool:_ascending forKey:CPSortDescriptorAscendingKey];
159 [aCoder encodeObject:CPStringFromSelector(_selector) forKey:CPSortDescriptorSelectorKey];