jeudi 21 juillet 2016
current location click then throw error swift
@IBAction func btnCurrentLocationClick(sender: UIButton)
{
self.zoomToLocation(mapView.userLocation.coordinate, animated: true)
SVProgressHUD.showWithStatus("Please wait...", maskType: .Clear)
delay(1.0) {
print("Hello!")
SwiftLocation.shared.reverseCoordinates(Service.GoogleMaps, coordinates: self.centerLocation, onSuccess: { (place) -> Void in
SVProgressHUD.dismiss()
let placemark:CLPlacemark! = place
let dicAddress:NSDictionary! = placemark.addressDictionary
let formattedAddress = dicAddress["FormattedAddressLines"] as! NSArray
let address = formattedAddress.componentsJoinedByString(", ")
let udefault=NSUserDefaults.standardUserDefaults()
udefault.setValue(address, forKey: "pDescript")
udefault.setDouble(self.centerLocation.latitude, forKey: "leti")
udefault.setDouble(self.centerLocation.longitude, forKey: "longi")
print(address)
}, onFail: { (error) -> Void in
alertShowWithToast((error?.localizedDescription)!);
SVProgressHUD.dismiss()
})
}
this is my code...if click current location button. then throw this error.
fatal error: unexpectedly found nil while unwrapping an Optional value
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire