1. Initialize the default user location with an invalid coordinate
2. Then check for the validity of the location.
let myLocation = CLLocation(latitude: kCLLocationCoordinate2DInvalid.latitude, longitude: kCLLocationCoordinate2DInvalid.longitude)
if CLLocationCoordinate2DIsValid(myLocation.coordinate) {
println("myLocation is valid!!")
} else {
println("myLocation is invalid!!")
}
If the user does not permit the device to access his/her location while using the app, the result is:
myLocation is invalid!!
No comments:
Post a Comment