2017-08-08 32 views
0

我有一個看起來像這樣的屬性:無法轉換CLLocationDegrees的價值預期參數shopProperties

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

我的問題是我將如何追加這個,所以我可以在我的課堂上訪問它?

+0

你究竟在哪條線上得到這個錯誤? – nayem

+0

On self.shopProperty.append(shopProper.Latitude) –

+0

「self.shopProperty」變量的類型是什麼? – nayem

回答

0

.shopProperty實例變量[shopProperties]類型是shopProperties陣列。所以你需要在你的數組中添加shopProperties類型的對象。但是你正在追加其他類型的對象。

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

self.shopProperty.append(shopProper) 

N.B:在一個側面說明,開始與資本的類名和小寫的屬性名稱。

相關問題