Created
January 16, 2016 14:11
-
-
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"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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