PFGeoPoint
Objective-C
@interface PFGeoPoint : NSObject <NSCopying, NSCoding>
Swift
class PFGeoPoint : NSObject, NSCopying, NSCoding
PFGeoPoint may be used to embed a latitude / longitude point as the value for a key in a PFObject.
It could be used to perform queries in a geospatial manner using PFQuery..
Currently, instances of PFObject may only have one key associated with a PFGeoPoint type.
-
Create a PFGeoPoint object. Latitude and longitude are set to
0.0.Declaration
Objective-C
+ (nonnull instancetype)geoPoint;Return Value
Returns a new
PFGeoPoint. -
Creates a new
PFGeoPointobject for the givenCLLocation, set to the location’s coordinates.Declaration
Objective-C
+ (nonnull instancetype)geoPointWithLocation:(nullable CLLocation *)location;Swift
convenience init(location: CLLocation?)Parameters
locationInstace of
CLLocation, with set latitude and longitude.Return Value
Returns a new PFGeoPoint at specified location.
-
Create a new
PFGeoPointobject with the specified latitude and longitude.Declaration
Objective-C
+ (nonnull instancetype)geoPointWithLatitude:(double)latitude longitude:(double)longitude;Swift
convenience init(latitude: Double, longitude: Double)Parameters
latitudeLatitude of point in degrees.
longitudeLongitude of point in degrees.
Return Value
New point object with specified latitude and longitude.
-
Fetches the current device location and executes a block with a new
PFGeoPointobject.@discussion You should not block the main thread while calling this method, as underneath, it makes a call to UIApplication.applicationState that requires to be on the main thread.
If you were to use a semaphore wait/signal to ‘wait’ for the result, you’d effectively deadlock your app.
Declaration
Objective-C
+ (void)geoPointForCurrentLocationInBackground: (nullable PFGeoPointResultBlock)resultBlock;Swift
class func geoPointForCurrentLocation(inBackground resultBlock: PFGeoPointResultBlock? = nil)Parameters
resultBlockA block which takes the newly created
PFGeoPointas an argument. It should have the following argument signature:^(PFGeoPoint *geoPoint, NSError *error)
-
Latitude of point in degrees. Valid range is from
-90.0to90.0.Declaration
Objective-C
@property (nonatomic) double latitude;Swift
var latitude: Double { get set } -
Longitude of point in degrees. Valid range is from
-180.0to180.0.Declaration
Objective-C
@property (nonatomic) double longitude;Swift
var longitude: Double { get set }
-
Get distance in radians from this point to specified point.
Declaration
Objective-C
- (double)distanceInRadiansTo:(nullable PFGeoPoint *)point;Swift
func distanceInRadians(to point: PFGeoPoint?) -> DoubleParameters
pointPFGeoPointthat represents the location of other point.Return Value
Distance in radians between the receiver and
point. -
Get distance in miles from this point to specified point.
Declaration
Objective-C
- (double)distanceInMilesTo:(nullable PFGeoPoint *)point;Swift
func distanceInMiles(to point: PFGeoPoint?) -> DoubleParameters
pointPFGeoPointthat represents the location of other point.Return Value
Distance in miles between the receiver and
point. -
Get distance in kilometers from this point to specified point.
Declaration
Objective-C
- (double)distanceInKilometersTo:(nullable PFGeoPoint *)point;Swift
func distanceInKilometers(to point: PFGeoPoint?) -> DoubleParameters
pointPFGeoPointthat represents the location of other point.Return Value
Distance in kilometers between the receiver and
point.
View on GitHub
Install in Dash