gpt4 book ai didi

ios - 无法将 CLLocationDegrees 的值转换为预期参数 shopProperties

转载 作者:行者123 更新时间:2023-11-30 12:14:55 24 4
gpt4 key购买 nike

我有一个如下所示的属性:

class shopProperties: NSObject {
var Latitude: CLLocationDegrees?
}

当我执行这段代码时:

 databaseRef.observeSingleEvent(of: .value, with: { (snapshot) in
for child in snapshot.children {
let snap = child as! FIRDataSnapshot
let dictionary = snap.value as! [String: AnyObject]
let shopProper = shopProperties()

var latitude = dictionary["Latitude"]
var longtitude = dictionary["Longtitude"]

shopProper.Latitude = latitude as! CLLocationDegrees
print(shopProper.Latitude)
self.shopProperty.append(shopProper.Latitude)
})

我在构建时的编译器错误中收到此错误:

无法将 CLLocationDegrees 的值转换为预期参数 shopProperties

我的问题是我如何附加它以便我能够在我的类里面访问它?

最佳答案

您的.shopProperty实例变量的类型为[shopProperties],即shopProperties数组。因此,您需要将 shopProperties 类型对象附加到数组中。但您正在附加其他类型的对象。

将此 self.shopProperty.append(shopProper.Latitude) 更改为

self.shopProperty.append(shopProper)

注意:附注,类名以大写开头,属性名称以小写开头。

关于ios - 无法将 CLLocationDegrees 的值转换为预期参数 shopProperties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45557781/

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