mem*_*ons 6 generics uitableview ios swift
protocol Configurable {
}
class CoolConfiguration : Configurable {
}
class GenericTableViewCell<T: Configurable>: UITableViewCell {
}
class CoolTableViewCell : GenericTableViewCell<CoolConfiguration> {
init(aDecoder: NSCoder) {
/* The init() method doesn't work below...so no way to override
the init properly. Seems like this should work -- GenericTableViewCell is
_still_ a subclass of UITableViewCell, so what the heck?
*/
super.init(aDecoder)
/* Additionally if you look in CoolTableViewCell.xib, you'll see there is no way
to set this class in the class dropdown. So, I can't set the view manually by
loading a nib here in the init and I can't set this class as the class to be
used in the nib.
*/
}
}
Run Code Online (Sandbox Code Playgroud)
上面代码中的注释解释了这个问题。有趣的是,在 xib 中,我可以看到 theGenericTableViewCell作为类下拉列表中的一个选项,它甚至不应该工作,因为T: Configurable不会设置泛型。
答案可能是“不适用于 Objective-C 类”,但希望我是错的。有任何想法吗?
| 归档时间: |
|
| 查看次数: |
290 次 |
| 最近记录: |