Skip to content

Instantly share code, notes, and snippets.

@bhargavg
Created January 16, 2016 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhargavg/ccb666a0c0ed94f7cd19 to your computer and use it in GitHub Desktop.
Save bhargavg/ccb666a0c0ed94f7cd19 to your computer and use it in GitHub Desktop.
Code fails with error: "protocol 'ViewModel' can only be used as a generic constraint because it has Self or associated type requirements"
import Foundation
protocol ViewModel {
typealias ModelType
var data: ModelType { get }
}
struct ViewContainer {
var viewModels: [ViewModel]
init() {
viewModels = [ViewModel]()
}
mutating func add(model: ViewModel) {
viewModels.append(model)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment