class EditProfileViewController: UITableViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, CLLocationManagerDelegate, UITextViewDelegate {
var manager:CLLocationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
if iOS8 {
manager.requestWhenInUseAuthorization()
}
manager.startUpdatingLocation()
aboutText.delegate = self
}
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
if locations.count > 0 {
self.manager.stopUpdatingLocation()
let location = locations[0] as! CLLocation
var currentLocation = PFGeoPoint(location: location)
}
}
@IBAction func singlecomparepost(sender: AnyObject) {
post["location"] = currentLocation
post.saveInBackground()
}
Thats how my code is but i cant access "currentLocation" at the singlecomparepost function.Is there a way to set the location as a variable for the whole view controller?
Aucun commentaire:
Enregistrer un commentaire