2016-08-31 3 views
0

cllocationcoordinate2dをcllocationに変換しようとしています。私は以下のコードの12行目で "Container literalで期待される式"というエラーを受け取ります。また、13行目の "cllocationcoordinate2dの値を期待値cllocationに変換できません"というエラーが表示されますが、これは12行目が正しく動作していないためです。CLLocationCoordinate2DをSwiftのCLLocationに変換する際のエラー

@IBAction func makeEvent(sender: UIButton) 
    { 
     let center = CLLocationCoordinate2D(latitude: loc1.coordinate.latitude, longitude: loc1.coordinate.longitude) 
     let lat: CLLocationDegrees = center.latitude 
     let long: CLLocationDegrees = center.longitude 
     self.pointAnnotation1 = MKPointAnnotation() 
     self.pointAnnotation1.title = "Event" 
     self.pointAnnotation1.coordinate = CLLocationCoordinate2D(latitude: lat, longitude: long) 
     self.pinAnnotationView = MKPinAnnotationView(annotation: self.pointAnnotation1, reuseIdentifier: nil) 
     self.mapView?.centerCoordinate = self.pointAnnotation1.coordinate 
     self.mapView.addAnnotation(self.pinAnnotationView.annotation!) 
     CLLocation *center = [[CLLocation alloc] initWithLatitude:latt longitude:longg] 
     eventRecord.setObject(center, forKey: "event") 
     let publicData = CKContainer.defaultContainer().publicCloudDatabase 
     publicData.saveRecord(eventRecord) { record, error in 
     } 
     if error == nil 
     { 
      print("Location saved") 
     } 
     loadEvent(){ (error, records) in 
      if error != nil { 
       print("error fetching locations") 
      } else { 
       print("Found Event") 
      } 
     } 
    } 
+1

を 'CLLocation *中心= [[CLLocation ALLOC] initWithLatitude:LATT経度:longg]は'のObjective-C、ないスウィフトあります。 –

答えて

3

目的をcとスピーディーに混ぜています。 これを試してください。

let center = CLLocation(latitude: lat, longitude: long) 

代わりの:

CLLocation *center = [[CLLocation alloc] initWithLatitude:latt longitude:longg] 
関連する問題