CLLocationCoordinate2D can't be instantiated

做~自己de王妃 提交于 2021-01-20 07:32:10

问题


I am trying to create some "CLLocation"s from data that I've read from a file. The first step is to instantiate a "CLLocationCoordinate2D" to be fed into the initializer for CLLocation. I'm trying out my ideas in a Playground and this very simple code generates a runtime error:

import CoreLocation

let lat = 48.8
let lon = -122.3
let point2D = CLLocationCoordinate2D(latitude: lat, longitude: lon)

Error message is

error: Execution was interrupted, reason: signal SIGABRT.
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

I am pretty new to Swift programming and I have no idea what to do with any of this. E.g., how do I "use "thread return -x" " to do anything Can anyone tell me what's going on here?

I've tried to attach a picture of the whole playground but can't tell if that is possible


回答1:


Frankenstein was right - it must be an Xcode bug. I put the same code in a "real" program and no problem.




回答2:


Just happened to me. Try to replace import CoreLocation with import MapKit that's worked in me case.



来源:https://stackoverflow.com/questions/62762553/cllocationcoordinate2d-cant-be-instantiated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!