タイトルの通りです.
Swift3初心者です.
swift3
1private func locationManager(_ manager: CLLocationManager, 2 didUpdateLocations locations: [CLLocation]) -> Double{ 3 let locationData = locations.last 4 if var ido = locationData?.coordinate.latitude{ 5 ido = round(ido*1000000)/1000000 6 return Double(ido) 7 } 8 }
というように定義しており,Double型で緯度の値を返すようにしたのですが,
Swift3
1 class ViewController: UIViewController, ARSCNViewDelegate, CLLocationManagerDelegate{ 2 3 var locationManager = CLLocationManager() 4 var locationData : CLLocation? = nil 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 9 … 10 11 var ido:Double = 0.0 12 ido = locationManager(locationManager,locationData) //Cannot call value of non-function type 'CLLocationManager'というエラーが出る 13 14 if ido > 35.689634 { 15 16 … 17 18 } 19 } 20}
のため困っております.
そもそも,Double型で値を返すことができないんでしょうか?
また,前回同じような質問内容で投稿させていただき,ベストアンサーの方に教えていただいたようにしたのですが,値がnilとなっており,35.689634の値と比較ができませんでした.
前回の質問内容
その時に教えていただいたコードが以下のようになります
swift3
1import SceneKit 2import ARKit 3import CoreLocation 4import UIKit 5 6class ViewController: UIViewController, ARSCNViewDelegate, CLLocationManagerDelegate{ 7 8 var locationManager = CLLocationManager() 9 var locationData:CLLocation? = nil 10 11 12 func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){ 13 14 locationData = locations.last 15 ... 16 } 17 18 override func viewDidLoad() { 19 super.viewDidLoad() 20 21 .... 22 if let locationData = locationData, locationData.coordinate.latitude >= 35.689634 { 23 //この時のlocationData.coodinate.latitudeの値がnilとなっている 24 scene.rootNode.addChildNode(sphere3Node) 25 } 26 } 27}
よろしくおねがいいたします.
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/03 12:27
2018/04/03 12:37
2018/04/03 12:39
2018/04/03 12:47
2018/04/03 23:10