Instance Method


Initializes and returns a location sort descriptor object.


- (instancetype)initWithKey:(NSString *)key relativeLocation:(CLLocation *)relativeLocation;



The name of the key whose value is a CLLocation object. The key must belong to the records being sorted. The sort descriptor uses this key to retrieve the corresponding value from the record.


The reference location to use when sorting. Records are sorted based on their distance to this location.

Return Value

An initialized location sort descriptor object, or nil if the object cannot be initialized.


During sorting, the sort descriptor computes the distance between the value in the relativeLocation parameter and the location value found in the specified key of each record. It then sorts the records in ascending order using the distance between the two points. You cannot change the sort order.

See Also

Initializing a Location Sort Descriptor