2017-02-21 14 views
-1

나는 내 구글지도에서 좌표를 얻고 나는 플로트 변수에 할당 할,하지만이 오류 보여줍니다수정 방법 : 'CLLocationDegrees'(일명 'Double') 유형의 값을 'Float!'유형에 할당 할 수 없습니다. 스위프트의 3

Cannot assign value of type 'CLLocationDegrees' (aka 'Double') to type 'Float!'

func markerButtonClicked(sender:MapButton) { 
let coord = self.getCenterCoordinate() 
    let addressObj = Address() 
    addressObj.latitude = coord.latitude 
    addressObj.longitude = coord.longitude 
} 
func getCenterCoordinate() -> (CLLocationCoordinate2D) { 
    let location = CGPoint(x:self.mView.bounds.size.width/2,y:self.mView.bounds.size.height/2) 
    let coord = self.mView.projection .coordinate(for: location) 
    return coord 
}  

class Address: NSObject { 
    var latitude:Float! 
    var longitude:Float! 
} 
+1

변경 ** var 위도 : Double !, var 경도 : Double! ** –

답변

2

이 떠있는 귀하의 값을 변환하고

를 할당을
addressObj.latitude = Float(coord.latitude) 
addressObj.longitude = Float(coord.longitude)