gpt4 book ai didi

ios - swift 非空函数应该在 guard let 中返回一个值

转载 作者:搜寻专家 更新时间:2023-11-01 06:12:20 27 4
gpt4 key购买 nike

    guard let cell = tableView
.dequeueReusableCell(withIdentifier: cellIdentifier) as? FolderAndFileCell else {
print("some")
return
}

上面写着

Non-void function should return a value

我应该在这里返回什么?

最佳答案

cellForRowAt 中你必须

guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as? FolderAndFileCell else {
print("some")
return UITableViewCell()
}

这个签名

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

应该有一个非空的返回值


众所周知的方法是

 let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) as! FolderAndFileCell

关于ios - swift 非空函数应该在 guard let 中返回一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53108462/

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