Skip to content

Instantly share code, notes, and snippets.

@mitulmanish
Created April 8, 2018 02:22
Show Gist options
  • Save mitulmanish/d035bdc05ee6f42bc9e3f16e78ab0c3a to your computer and use it in GitHub Desktop.
Save mitulmanish/d035bdc05ee6f42bc9e3f16e78ab0c3a to your computer and use it in GitHub Desktop.
class MoviesViewModel: ViewModelProtocol {
var resourceType: ResourceType {
return .movies
}
var items: [Movie] = [Movie]()
typealias Item = Movie
required init?() {
guard let data = try? getData(forResourceType: resourceType) else {
return nil
}
items = extractItems(fromData: data)
}
func imageUrl(forIndex index: Int) -> String? {
return items[index].sanitizedImageUrlString
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment