要运行示例项目,首先克隆仓库,然后从示例目录运行pod install
。更多文档,请访问CocoaDocs页面。
使用TacoShell执行一个GET
请求非常简单,就像这样
TacoShell *ts = [[TacoShell alloc] initWithURL:[NSURL URLWithString:@"http://guacamole.burritokit.com/"]];
ts.completionBlock = ^(NSDictionary *dictionary, NSInteger httpResponseStatusCode, id response){
NSLog(@"Your IP Address is: %@", response[@"meta"][@"ip"]);
};
[ts start];
就这样!TacoShell会自动反序列化包含application/json
的相应Content-Type
的内容。
要使用multipart/form-data
执行POST
请求,只需将所需字段传递给POSTDictionary
。
...
ts.method = BKTSRequestMethodPOST;
ts.POSTDictionary = @{"username": "karl"};
...
如果没有指定Content-Type
,并且设置了POSTDictionary
,则Content-Type
将默认为multipart/form-data
。
如果您要将POSTDictionary
以JSON
的形式放在Body
中,则请像这样设置Content-Type
为BKTSRequestContentTypeApplicationJSON
...
ts.contentType = BKTSRequestContentTypeApplicationJSON;
...
很简单,不是吗?
Marcus Kida,[email protected]
TacoShell可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。