Skip to content

Instantly share code, notes, and snippets.

@nunogoncalves
Last active May 28, 2016 08:49
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 nunogoncalves/8131dae2aec22f19c9f6b3a4c6e8e95e to your computer and use it in GitHub Desktop.
Save nunogoncalves/8131dae2aec22f19c9f6b3a4c6e8e95e to your computer and use it in GitHub Desktop.
protocol Deserializable {
associatedtype T: Deserializer
var deserializer: T { get }
func getDataFrom(dictionary: NSDictionary) -> T.MappedObject
}
extension Deserializable {
func getDataFrom(dictionary: NSDictionary) -> T.MappedObject {
return deserializer.buildFrom(dictionary)
}
}
protocol Deserializer {
associatedtype MappedObject
func buildFrom(dictionary: NSDictionary) -> MappedObject
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment