I'm working on a iPhone App and have a little question. I have a function and want to call this function in my viewDidLoad-function. I have tried this way but I get an error when I want to call the dropPin-function.
override func viewDidLoad() {
super.viewDidLoad()
//drop the pin when view did load !Missing argument for parameter ¨didUpdateLocation¨ in call!
dropPin(CLLocationManager, didUpdateLocations: [CLLocation])
}
func dropPin(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last
let center = CLLocationCoordinate2D (latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)
//initialize our Pin with our coordinates and the context from AppDelegate
let pin = Pin(annotationLatitude: center.latitude, annotationLongitude: center.longitude, context: appDelegate.managedObjectContext!)
//add the annotation to the map
mapView.addAnnotation(pin)
//save our context. We can do this at any point but it seems like a good idea to do it here.
appDelegate.saveContext()
}
Thanks for your help!