I'm having an array of objects. Now I want to force that those objects are implementing Comparable.
So I created a protocol like this:
protocol Foo: Comparable { }
Everything goes fine except when I create the array:
let array: [Foo] = [obj1, ..]
Then suddenly the compiler complains:
Protocol 'Foo' can only be used as a generic constraint because it has Self or associated type requirements
Is there another way to do this?
EDIT
class View: UIView {
let viewModel: SomeViewModel
}
class SomeViewModel {
let views: [UIView]
}