gpt4 book ai didi

ios - "Ambiguous reference to member ' 计数 ' "错误

转载 作者:行者123 更新时间:2023-11-28 08:06:23 25 4
gpt4 key购买 nike

我不太擅长使用 swift.. 但我一直在尝试使用 firebase 作为后端创建一个社交媒体应用程序。但是我被困在数据存储在数组中的这一部分......但是当.我调用数组,我不断收到“对成员‘计数’的模糊引用”错误,我尝试了很多方法来解决这个问题,但每次都以失败告终

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

最佳答案

你可能想在这里使用 value(forKey:)

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

关于ios - "Ambiguous reference to member ' 计数 ' "错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44981510/

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