2017-07-08 114 views
1

我不是那麼多使用swift的專業人士..但我一直在嘗試創建一個使用Firebase作爲後端的社交媒體應用程序。但是我被困在這個數據被存儲在一個數組中的部分。我叫我不斷收到「不明確提及成員‘計數’」錯誤的陣列,我已經嘗試了許多方法來解決這個問題,但最終未果每次「對成員'count'的歧義引用」「錯誤

var posts = [AnyObject?]() 

override func viewDidLoad() { 
    super.viewDidLoad() 

} 

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    let cell: HomeViewTableViewCell = tableView.dequeueReusableCell(withIdentifier: "HomeViewTableViewCell", for: indexPath) as! HomeViewTableViewCell 

    let post = (posts[(self.posts.count - 1) - indexPath.row] as AnyObject).value["text"] as! String //**Ambiguous reference to member 'count' 

    cell.configure(nil,NameText:self.loggedInUserData!.value["NameText"] as! String, TitleText:self.loggedInUserData!.value["TitleText"] as! String, post:post) 

    return cell 
} 

請幫幫忙!

實際上是試圖本教程出的Youtube ......所以,如果需要完整的代碼,這是YouTube鏈接:

https://www.youtube.com/watch?v=BeZ3i7-gaok&list=PLy9JCsy2u97kro0jXbXrPFmT-DQVAmNW0&index=4

回答

0

您可能需要使用的值(forKey :)這裏

let post = (posts[(self.posts.count - 1) - indexPath.row] as AnyObject).value(forKey: "text") 
+0

謝謝soo!有效! :) –

相關問題