简化NSURLSession的包装项目。
platform :ios, '8.0'
pod 'CoreNetworking', '~> 1.0'
将文件夹/CoreNetworking-iOS
拖入您的项目中。这就完成了。
#import "CNMSession.h"
#import "CNMRequest.h"
#import "CNMURLSessionDataTask.h"
...
CNMRequest *request = [[CNMRequest alloc] init];
request.URL = [NSURL URLWithString:@"http://exampleapi.com/json"];
CNMURLSessionDataTask *task = [[CNMSession defaultSession] dataTaskFromRequest:request];
task.onCompletion = ^void(NSData *data, NSURLResponse *response, NSError *error)
{
if (!error)
{
// Raw data to JSON.
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data
options: NSJSONReadingMutableContainers
error: nil];
}
else
{
NSLog(@"error %@", error);
}
};
[task resume];
ButtonBackgroundColor-iOS遵守MIT许可证。请参阅名为LICENSE的文件。
$ git tag -a 1.0.0 -m 'Version 1.0.0'
$ git push --tags
Gabriel Massana
如果您遇到CoreNetworking-iOS特定的难题,或者有大功能请求,或者想留下评论,请在这里新建问题。