大佬教程收集整理的这篇文章主要介绍了将CLLocationDegrees更改为Double/NSNumber以保存在Core Data(Swift)中,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我只是想将CLLOCATIOndegrees值保存到Core Data中.但我所做的一切都在起作用.
我开始时:
self.myLOCATIOn?.LOCATIOnCurrentLat = self.fixedLOCATIOn?.coordinate.latitude
但是不知道如何让CLLOCATIOndegrees向Double或NSnumber投降(如果这是正确的话),我在Google上搜索的任何东西都无济于事!
关于很多事情,我显然仍然模糊不清.这肯定是其中之一.
我可能做错了什么……或者需要做什么?
提前致谢
如果确实需要将其强制转换为double,请使用语法
Double(self.fixedLOCATIOn?.coordinate.latitude ?? 0)
要转换为NSnumber,您可以使用
NSnumber(value: self.fixedLOCATIOn?.coordinate.latitude ?? 0)
编辑:
我编辑了上面的代码,如果self.fixedLOCATIOn为nil,则使用“nil coalescing operator”给出值0.如果fixedLOCATIOn为nil,则返回包含nil的可选Int会更安全:
let latitude: Double? if let LOCATIOn = self.fixedLOCATIOn { latitude = Double(LOCATIOn.coordinate.latitudE) } else { latitude = nil }
以上是大佬教程为你收集整理的将CLLocationDegrees更改为Double/NSNumber以保存在Core Data(Swift)中全部内容,希望文章能够帮你解决将CLLocationDegrees更改为Double/NSNumber以保存在Core Data(Swift)中所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。