如何提取函数变量值并将其初始化为另一个函数中的另一个变量?

时间:2015-08-06 14:59:40

标签: ios swift variables func

这是我的两个函数,我想将信息从函数转换到另一个,而不需要声明一个变量来存储信息,因为总是当我启动我的应用程序时,初始变量是显示的那个

    func action(gestureRecognizer: UIGestureRecognizer) {

    var touchPoint = gestureRecognizer.locationInView(self.mapView)
    var location:CLLocationCoordinate2D = mapView.convertPoint(touchPoint, toCoordinateFromView: self.mapView)
    var latDelta:CLLocationDegrees = 0.01
    var lonDelta:CLLocationDegrees = 0.01
    var span:MKCoordinateSpan = MKCoordinateSpan(latitudeDelta:latDelta, longitudeDelta: lonDelta)
    var region:MKCoordinateRegion = MKCoordinateRegion(center: location, span: span)
    mapView.setRegion(region, animated: true)

    var annotation = MKPointAnnotation()
    annotation.coordinate = location
    annotation.title = ""        
}

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {

    var userLocation:CLLocation = locations[0] as! CLLocation

    CLGeocoder().reverseGeocodeLocation(userLocation, completionHandler: { (placeMarks, error) -> Void in

     if error != nil 
     {
         println("error: \(error)")
     }
      else {
         let place = CLPlacemark(placemark: placeMarks?[0] as! CLPlacemark)
            }
     })

}

0 个答案:

没有答案