Last active
October 2, 2019 03:48
-
-
Save hassanvfx/176a3a81588a8433a443aa14cbb2b618 to your computer and use it in GitHub Desktop.
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 UIKit | |
import ObjectMapper | |
protocol APIResponse { | |
func items<K>(_ type:K.Type? )->[K] | |
} | |
extension APIResponse{ | |
func items<K>(_ type:K.Type? = nil)->[K]{ | |
return ([self] as? [K]) ?? [] | |
} | |
} | |
extension Movie: APIResponse{} | |
struct APIResponseMovieList: Mappable,APIResponse { | |
var page: Int? | |
var results: [Movie]? | |
init?(map: Map) { | |
} | |
mutating func mapping(map: Map) { | |
page <- map["page"] | |
results <- map["results"] | |
} | |
func items<K>(_ type:K.Type? = nil)->[K]{ | |
return (results as? [K]) ?? [] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment