0
cllocationcoordinate2d를 cllocation으로 변환하려고합니다. 아래 코드 12 행의 "Container literal에서 Expected expression"오류가 발생합니다. 나는 또한 라인 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")
}
}
}
'CLLocation의 * 센터 = [CLLocation의 ALLOC]을 initWithLatitude : 라트 경도 : longg] '오브젝티브 C, 스위프트 아니다. –