xcode – geocoder.geocodeAddressString今天不再适用于swift更新

xcode – geocoder.geocodeAddressString今天不再适用于swift更新,第1张

概述https://developer.apple.com/library/prerelease/mac/releasenotes/General/APIDiffsMacOSX10_11/Swift/CoreLocation.html 表明有一些变化 func geocodeAddressString(_ addressString: String!, completionHandler comple https://developer.apple.com/library/prerelease/mac/releasenotes/General/APIDiffsMacOSX10_11/Swift/CoreLocation.html

表明有一些变化

func geocodeAddressstring(_ addressstring: String!,completionHandler completionHandler: CLGeocodeCompletionHandler!)

至:

func geocodeAddressstring(_ addressstring: String,completionHandler completionHandler: CLGeocodeCompletionHandler)

我的代码是:

var geocoder = CLGeocoder()geocoder.geocodeAddressstring("\(event!.street),\(event!.city),\(event!.country)",completionHandler: {(placemarks: [AnyObject]!,error: NSError!) -> VoID in    if let placemark = placemarks?[0] as? CLPlacemark {        self.event!.lat = placemark.location!.coordinate.latitude        self.event!.long = placemark.location!.coordinate.longitude        self.event!.getMiles(self.currentLocation!.location!.coordinate.latitude,clong: self.currentLocation!.location!.coordinate.longitude)        var mile = self.event!.miles != nil ? Nsstring(format: "%.1f miles",self.event!.miles!) : "Location services off"        self.milesbutton.setTitle(mile as String,forState: .normal)    }})

尝试:

var geocoder = CLGeocoder()let address = "\(event!.street),\(event!.country)"geocoder.geocodeAddressstring(address,completionHandler: {(placemarks: [CLPlacemark]) in     let placemark = placemarks[0]     self.event!.lat = placemark.location!.coordinate.latitude     self.event!.long = placemark.location!.coordinate.longitude     self.event!.getMiles(self.currentLocation!.location!.coordinate.latitude,clong: self.currentLocation!.location!.coordinate.longitude)     var mile = self.event!.miles != nil ? Nsstring(format: "%.1f miles",self.event!.miles!) : "Location services off"     self.milesbutton.setTitle(mile as String,forState: .normal)})

它只是说它不被允许.尝试了几种不同的组合.这是对xcode / swift的最新更新

提前致谢

解决方法 以这种方式使用geocodeAddressstring:

geocoder.geocodeAddressstring(address,completionHandler: {(placemarks: [CLPlacemark]?,error: NSError?) -> VoID in})

它会工作正常.

总结

以上是内存溢出为你收集整理的xcode – geocoder.geocodeAddressString今天不再适用于swift更新全部内容,希望文章能够帮你解决xcode – geocoder.geocodeAddressString今天不再适用于swift更新所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1036489.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存