extension DataSourceProtocolProvider {
func createDataSource<T: DataSourceProtocol>(dataSource: T)
where T.DataSourceItem == Item {
}
}
On the createDataSource<T: DataSourceProtocol> declaration I get the following warning:
Redundant superclass constraint 'T.DataSourceItem' : 'NSManagedObject'
I thought that you could specify that an associatedtype could be used with the == operator to constrain the associatedtype to a specific type. I want to have a func createDataSource<T: DataSourceProtocol>(dataSource:T) where the DataSourceItem is an Item.
If I replace the == operator with : then the warning goes away:
extension DataSourceProtocolProvider {
func createDataSource<T: DataSourceProtocol>(dataSource: T)
where T.DataSourceItem : Item {
}
}
This happens to be a completely different context now. This constraint specifies that I want to have a func createDataSource<T: DataSourceProtocol>(dataSource:T) where the DataSourceItem is a subclass of Item. Which isn't the same thing as DataSourceItem is an Item object. Also, the code runs fine with == so am I just not understanding how constraints work?
extension DataSourceProtocolProvider {
func createDataSource<T: DataSourceProtocol>(dataSource: T)
where T.DataSourceItem == Item {
}
}
On the createDataSource<T: DataSourceProtocol> declaration I get the following warning:
I thought that you could specify that an associatedtype could be used with the == operator to constrain the associatedtype to a specific type. I want to have a func createDataSource<T: DataSourceProtocol>(dataSource:T) where the DataSourceItem is an Item.
If I replace the == operator with : then the warning goes away:
extension DataSourceProtocolProvider {
func createDataSource<T: DataSourceProtocol>(dataSource: T)
where T.DataSourceItem : Item {
}
}
This happens to be a completely different context now. This constraint specifies that I want to have a func createDataSource<T: DataSourceProtocol>(dataSource:T) where the DataSourceItem is a subclass of Item. Which isn't the same thing as DataSourceItem is an Item object. Also, the code runs fine with == so am I just not understanding how constraints work?