测试已测试 | ✓ |
Lang语言 | Obj-CObjective C |
许可 | MIT |
Released最后发布 | 2014年12月 |
由 无人认领 维护。
依赖项 | |
AFNetworking | = 2.1.0 |
ReactiveCocoa | = 2.2.3 |
ISO8601DateFormatter | = 0.7 |
Mantle | = 1.3.1 |
Treasure Data REST API 的 Objective-C 客户端库,由 Treasure Data REST API 构建,使用 AFNetworking、Mantle 和 ReactiveCocoa 开发。
platform :ios, '7.0'
pod "TreasureData", "~> 0.1.0"
TRDClient
上的每个请求方法都会返回一个 ReactiveCocoa 信号。
Treasure Data REST API 使用 API 密钥进行认证。请参阅 API 文档。
您可以直接使用 API 密钥创建客户端。
TRDApiKey *apiKey = [TRDApiKey apiKeyWithValue:@"TD_API_KEY"];
TRDClient *client = [[TRDClient alloc] initWithApiKey:apiKey];
如果您想使用电子邮件和密码进行认证,可以使用 authenticateWithUsername:password
。
[[TRDCLient authenticateWithUsername:@"email" password:@"pass"] subscribeNext:^(TRDClient *client) {
NSLog("apiKey: %@" client.apiKey.value);
}];
通常,单独处理每个结果对象是有意义的,您可以将任何处理工作分散开来,而不是一次性完成。
RACSingal *request = [cleint fetchAllDatabases];
[request subscribeNext:^(TRDDatabaes *database) {
// This block is invoked for _each_ result received, so you can deal with
// them one-by-one as they arrive.
} error:^(NSError *error) {
// Invoked when an error occurs.
//
// Your `next` and `completed` blocks won't be invoked after this point.
} completed:^{
// Invoked when the request completes and we've received/processed all the
// results.
//
// Your `next` and `error` blocks won't be invoked after this point.
}];
如果您必须等到所有结果都准备好了才能进行操作,您可以将它们收集到一个单独的数组中。
RACSingal *request = [cleint fetchAllDatabases];
[[request collect] subscribeNext:^(NSArray *databases) {
// Thanks to -collect, this block is invoked after the request completes,
// with _all_ the results that were received.
} error:^(NSError *error) {
// Invoked when an error occurs. You won't receive any results if this
// happens.
}];
MIT 许可证。