一个允许用户轻松查询电影和演员信息的 TMDB API 客户端。
要运行示例项目,先克隆仓库,然后从 Example 目录运行 pod install
。
此项目依赖于 AFNetworking。
其他要求
在您的应用Delegate中设置您的API密钥
代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[KMMTMDBAPIClient client] setAPIKey:@"MY API KEY"];
return YES;
}
在您的ViewController中查询API
代码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[KMMTMDBAPIClient client] popularMoviesInPage:1 complete:^(id results, NSError *error) {
NSDictionary *firstMovie = results[@"results"][0];
self.titleLabel.text = firstMovie[@"original_title"];
self.releaseDateLabel.text = firstMovie[@"release_date"];
self.popularityLabel.text = [@"Popularity: " stringByAppendingFormat: @"%f", [firstMovie[@"popularity"] doubleValue] ];
}];
}
KMMTMDBAPIClient 由 Kerr Marin Miller (@kerrmarin) 在开发 Dejavu 时开发。
KMMTMDBAPIClient 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。