{ case .Error(let error): callback(.Error(error)) case .Result(let json): var shows = [APIShow]() if let dicts = json.array { for dict in dicts { shows += APIShow(json: dict) } } callback(.Result(shows)) } } sendRequest(request, completion: handler)
{ self.title = title } if let stats = json["stats"] as? NSDictionary { if let watchers = stats["watchers"] as? NSNumber { self.watchers = watchers.integerValue } } if let people = json["people"] as? NSDictionary { if let actors = people["actors"] as? NSArray { for actor in actors { self.actors += APIActor(json: actor) } } } }
{ self.title = title } if let stats = json["stats"] as? NSDictionary { if let watchers = stats["watchers"] as? NSNumber { self.watchers = watchers.integerValue } } if let people = json["people"] as? NSDictionary { if let actors = people["actors"] as? NSArray { for actor in actors { self.actors += APIActor(json: actor) } } } }
{ self.title = title } if let watchers = (json["stats"] as? NSDictionary)?["watchers"] as? NSNumber { self.watchers = watchers.integerValue } if let actors = (json["people"] as? NSDictionary)?["actors"] as? NSArray { for actor in actors { if let dict = actor as? NSDictionary { self.actors += APIActor(json: dict) } } } }
= title } if let watchers = json["stats"]["watchers"].number { self.watchers = Int(watchers) } if let actors = json["people"]["actors"].array { for actor in actors { if let dict = actor as? NSDictionary { self.actors += APIActor(json: dict) } } } }