Up

NSSortDescriptor class documentation

Authors

Generated by Gregory John Casamento,,,

Date: Generated at 2023-12-20 19:35:39 -0500


Contents -

  1. Software documentation for the NSSortDescriptor class
  2. Software documentation for the NSArray(NSSortDescriptorSorting) category
  3. Software documentation for the NSMutableArray(NSSortDescriptorSorting) category
  4. Software documentation for the NSSet(NSSortDescriptorSorting) category

Software documentation for the NSSortDescriptor class

NSSortDescriptor : NSObject

Declared in:
Foundation/NSSortDescriptor.h
Conforms to:
NSCopying
NSCoding
Availability: MacOS-X 10.3.0

Instances of this class are used to perform multi-level sorts of arrays containging collections or other objects whose properties can be obtained using key names.
Method summary

sortDescriptorWithKey: ascending: 

+ (id) sortDescriptorWithKey: (NSString*)aKey ascending: (BOOL)ascending;
Availability: MacOS-X 10.6.0

Returns an autoreleased sort descriptor for comparisons using the 'compare:' selector and the specified key and ordering.

See also -initWithKey:ascending: .


sortDescriptorWithKey: ascending: comparator: 

+ (id) sortDescriptorWithKey: (NSString*)key ascending: (BOOL)ascending comparator: (NSComparator)cmptr;
Availability: MacOS-X 10.6.0

Returns an autoreleased sort descriptor initialized to perform comparisons in the specified order using the comparator to compare the property aKey of each object.

See also -initWithKey:ascending:selector: .


sortDescriptorWithKey: ascending: selector: 

+ (id) sortDescriptorWithKey: (NSString*)aKey ascending: (BOOL)ascending selector: (SEL)aSelector;
Availability: MacOS-X 10.6.0

Returns an autoreleased sort descriptor initialized to perform comparisons in the specified order using aSelector to compare the property aKey of each object.

See also -initWithKey:ascending:selector: .


ascending 

- (BOOL) ascending;
Availability: MacOS-X 10.3.0

Returns a flag indicating whether the sort descriptor sorts objects in ascending order ( YES) or descending order ( NO).

compareObject: toObject: 

- (NSComparisonResult) compareObject: (id)object1 toObject: (id)object2;
Availability: MacOS-X 10.3.0

Returns the result of comparing object1 to object2 using the property whose key is defined in the receiver and using the selector of the receiver. If the receiver performs a descending order sort, the result of this comparison is the opposite of that prroduced by applying the selector.

initWithKey: ascending: 

- (id) initWithKey: (NSString*)key ascending: (BOOL)ascending;
Availability: MacOS-X 10.3.0

Initialises the receiver for comparisons using the 'compare:' selector and the specified key and ordering.

initWithKey: ascending: comparator: 

- (id) initWithKey: (NSString*)key ascending: (BOOL)ascending comparator: (NSComparator)cmptr;
Availability: MacOS-X 10.6.0

This is a designated initialiser for the class.
Initialises the receiver to perform comparisons in the specified order using the comparator to compare the property key of each object.

initWithKey: ascending: selector: 

- (id) initWithKey: (NSString*)key ascending: (BOOL)ascending selector: (SEL)selector;
Availability: MacOS-X 10.3.0

This is a designated initialiser for the class.
Initialises the receiver to perform comparisons in the specified order using selector to compare the property key of each object.

key 

- (NSString*) key;
Availability: MacOS-X 10.3.0

Returns the key used to obtain the property on which comparisons are based.

reversedSortDescriptor 

- (id) reversedSortDescriptor;
Availability: MacOS-X 10.3.0

Returns a copy of the receiver which compares and sorts in reversed order.

selector 

- (SEL) selector;
Availability: MacOS-X 10.3.0

Returns the selector used to compare the properties of objects.

Software documentation for the NSArray(NSSortDescriptorSorting) category

NSArray(NSSortDescriptorSorting)

Declared in:
Foundation/NSSortDescriptor.h
Availability: MacOS-X 10.3.0

Description forthcoming.
Method summary

sortedArrayUsingDescriptors: 

- (GS_GENERIC_CLASS(NSArray,ElementT)*) sortedArrayUsingDescriptors: (NSArray*)sortDescriptors;
Availability: MacOS-X 10.3.0

Produces a sorted array using the mechanism described for [NSMutableArray(NSSortDescriptorSorting) -sortUsingDescriptors:]

Software documentation for the NSMutableArray(NSSortDescriptorSorting) category

NSMutableArray(NSSortDescriptorSorting)

Declared in:
Foundation/NSSortDescriptor.h
Availability: MacOS-X 10.3.0

Description forthcoming.
Method summary

sortUsingDescriptors: 

- (void) sortUsingDescriptors: (NSArray*)sortDescriptors;
Availability: MacOS-X 10.3.0

This method works like this: first, it sorts the entire contents of the array using the first sort descriptor. Then, after each sort-run, it looks whether there are sort descriptors left to process, and if yes, looks at the partially sorted array, finds all portions in it which are equal (evaluate to NSOrderedSame) and applies the following descriptor onto them. It repeats this either until all descriptors have been applied or there are no more equal portions (equality ranges) left in the array.

Software documentation for the NSSet(NSSortDescriptorSorting) category

NSSet(NSSortDescriptorSorting)

Declared in:
Foundation/NSSortDescriptor.h
Availability: MacOS-X 10.6.0

Description forthcoming.
Method summary

sortedArrayUsingDescriptors: 

- (GS_GENERIC_CLASS(NSArray,ElementT)*) sortedArrayUsingDescriptors: (NSArray*)sortDescriptors;
Availability: MacOS-X 10.6.0

Produces a sorted array from using the mechanism described for [NSMutableArray(NSSortDescriptorSorting) -sortUsingDescriptors:]


Up