gpt4 book ai didi

ios - 在 ViewController 上获取初始化程序错误

转载 作者:行者123 更新时间:2023-11-28 12:43:20 24 4
gpt4 key购买 nike

我收到错误消息:“类‘ViewController’没有初始化程序”。我已将问题缩小到正在调用的这个函数。有人看到问题了吗?

let locationManager1: CLLocationManager // your location manager
func addBoundry(loc: CLLocation)
{
if let loc: CLLocation! = locationManager1.location {
let center: CLLocationCoordinate2D = loc!.coordinate
let lat: CLLocationDegrees = center.latitude
let long: CLLocationDegrees = center.longitude
var points = [CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long),CLLocationCoordinate2DMake(lat,long)]
let polygon = MKPolygon(coordinates: &points, count: points.count)

mapView.addOverlay(polygon)

} else {
print("no location...")
}
}

最佳答案

当分配属性时使用可选的。

 let locationManager1: CLLocationManager?

关于ios - 在 ViewController 上获取初始化程序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38861641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com