[英]How to add multiple generic type constraints in Swift?
I have the following declaration: 我有以下声明:
TableViewDataSource
<Model: ManagedObject, Cell: UITableViewCell where Cell: ConfigurableCell> :
NSObject, UITableViewDataSource
I want to put a constraint on the Model type. 我想对Model类型施加约束。 Something like this:
像这样:
TableViewDataSource
<Model: ManagedObject where Model: ManagedObjectType,
Cell: UITableViewCell where Cell: ConfigurableCell> :
NSObject, UITableViewDataSource
How can I do that in Swift 2.0? 如何在Swift 2.0中做到这一点?
Put it like this instead, 这样说吧
TableViewDataSource
<Model:ManagedObject, Cell: UITableViewCell
where Model:ManagedObjectType, Cell:ConfigurableCell>:
NSObject,UITableViewDataSource
All generic types should to be first declared separated with delimeter(comma) and then constraints should be provided later and each constraint also should be separated with comma. 应该首先声明所有通用类型,并用delimeter(逗号)分隔,然后再提供约束,每个约束也应以逗号分隔。 All the constraints has to be fulfilled in order for it to work.
为了使它起作用,必须满足所有约束。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.