[英]Ambiguous reference to member 'tableView' when dequeuing a cell
I'm running into an odd error. 我遇到了一个奇怪的错误。 This line of code functions correctly:
这行代码可以正常运行:
let cell = self.tableView.dequeueReusableCellWithIdentifier("FeedCell", forIndexPath: indexPath) as UITableViewCell!
However when I cast to FeedCell!
但是,当我投射到
FeedCell!
(a subclass of UITableViewCell
): (
UITableViewCell
的子类):
let cell = self.tableView.dequeueReusableCellWithIdentifier("FeedCell", forIndexPath: indexPath) as FeedCell!
Xcode throws the error: Ambiguous reference to member 'tableView'
Xcode引发错误:
Ambiguous reference to member 'tableView'
I'm not sure how it can be ambiguous, let alone triggered by a different casting! 我不确定它是如何模棱两可的,更不用说是由其他转换触发的!
Try changing the line to 尝试将行更改为
let cell = tableView.dequeueReusableCellWithIdentifier("FeedCell", forIndexPath: indexPath) as! FeedCell
Just remove the ! 只需删除! from
FeedCell!
来自
FeedCell!
and put it in as!
并放入
as!
and check if there is any difference. 并检查是否有任何差异。
Beside as @redent84 mentioned in his comment you should use tableView
instead of self.tableView
. 除了在他的评论中提到的@ redent84之外,您还应该使用
tableView
而不是self.tableView
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.