Initializer

init(key:relativeLocation:)

Initializes and returns a location sort descriptor object.

Declaration

init(key: String, relativeLocation: CLLocation)

Parameters

key

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.

relativeLocation

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.

Discussion

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