[client requestGetWithPath:path parameters:parameters completion:^(NSArray *recipes, NSError *error) { if (nil == error) { } else { } }]; There are 4 possibilities The type of response is determined dynamically SFDJQFTOJM SFDJQFTOJM FSSPSOJM GBJMVSF FSSPSOJM TVDDFTT
10) let api = APIs.Recipes.Get(paginationParams: params) SharedAPIClient.sendRequest(api) { response in switch response { case .Success(let value): value[0].cookingTime case .Failure(let value): value.message } } The type of the response can be determined statically You can handle success and failure exhaustively
case Update, Publish var description: String { switch self { case .Update: return "updated_at" case .Publish: return "published_at" } } } case Desc(field: Field), Asc(field: Field) var description: String { switch self { case .Desc(let field): return "\(field)_desc" case .Asc(let field): return "\(field)_asc" } } } Enum can conform protocols Enum can have properties and functions You can associate a value with an enum let params = PaginationParams(order: .Desc(field: .Publish), page: 1, perPage: 10)
10) let api = APIs.Recipes.Get(paginationParams: params) SharedAPIClient.sendRequest(api) { response in switch response { case .Success(let value): value[0].cookingTime case .Failure(let value): value.message } } Enum Nested Classes Either Associated Value Protocol With Associated Type