这是我的协议(protocol):
protocol LiveTableViewCellProtocol: class {
var data: LiveCellObjectProtocol! { get set }
}
这是我的课:
class RepliesTableViewCell: UITableViewCell, LiveTableViewCellProtocol {
var data: RepliesCellObject! //ERROR! does not conform to protocol.
}
RepliesCellObject
定义为:
public class RepliesCellObject: NSObject , LiveCellObjectProtocol{
//basic stuff here.
}
RepliesCellObject
是一个 LiveCellObjectProtocol ...那么为什么我的表格单元格不符合要求?
最佳答案
它不符合,因为在符合 LiveTableViewCellProtocol 的对象中,您可以将数据设置为任何 LiveCellObjectProtocol,包括非 NSObject 的数据。在 RepliesTableViewCell 中,您不能这样做。数据必须设置为 LiveCellObjectProtocol,它也是一个 NSObject。
因此 RepliesTableViewCell 不符合 LiveTableViewCellProtocol。
关于ios - 类不符合协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38317051/