Skip to content

Instantly share code, notes, and snippets.

@mitulmanish
Created April 8, 2018 02:21
Show Gist options
  • Save mitulmanish/3ae6d6d229138f59358c8d01893bb4ec to your computer and use it in GitHub Desktop.
Save mitulmanish/3ae6d6d229138f59358c8d01893bb4ec to your computer and use it in GitHub Desktop.
class TVShowsViewModel: ViewModelProtocol {
var items: [TVShow] = [TVShow]()
typealias Item = TVShow
var resourceType: ResourceType {
return .tv
}
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