为iOS的无废话网络。
将CCHTTPRequest.h和CCHTTPRequest.m复制到您的Xcode项目中。
如果您正在使用CocoaPods,请将以下行添加到您的Podfile中
pod 'CCHTTPRequest'
步骤1:初始化CCHTTPRequest对象。
步骤2:设置完成和失败块。
步骤3:开始请求。
// Step 1. Create the request
CCHTTPRequest *aRequest = [[CCHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://graph.facebook.com/zowieso"]];
// Step 2. Set the completion and failure blocks
[aRequest setCompletionBlock:^(NSURLResponse *theResponse, NSData *theData) {
NSError *anError;
id aResponseJSON = [NSJSONSerialization JSONObjectWithData:theData options:NSJSONReadingAllowFragments error:&anError];
if (!anError) {
NSLog(@"%@", aResponseJSON);
}
} failureBlock:^(NSError *theError) {
NSLog(@"Request failed with error: %@", theError);
}];
// Step 3. Begin the request
[aRequest begin];
Cathy Shive,[email protected]
CCHTTPRequest可使用MIT许可证获取。有关更多信息,请参阅LICENSE文件。