AFNetworking 下载地址:https://github.com/AFNetworking/AFNetworking/

AFNetworking 2.0 当Deployment Target 低于6.0时,AFURLConnectionOperation.h,AFURLSessionManager.h

@property (nonatomic, strong) dispatch_queue_t completionQueue;

由于sdk低于6.0时,dispatch_queue_t  ARC没有托管,出现提示错误

 Property with 'retain (or strong)' attribute must be of object type

修改为

#if OS_OBJECT_USE_OBJC
@property (nonatomic, strong) dispatch_queue_t completionQueue;
#else
@property (nonatomic, assign) dispatch_queue_t completionQueue;
#endif

使用示例:(不使用官方的自带的json和xml解析,返回NSData)

1.0兼容版

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager GET:@"http://www.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) { }];

2.0

    AFHTTPSessionManager *httpSessionManager =[AFHTTPSessionManager manager];
httpSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSURLSessionDataTask *task = [httpSessionManager GET:@"http://www.com" parameters:nil success:^(NSURLSessionDataTask *task, id responseObject)
{ } failure:^(NSURLSessionDataTask *task, NSError *error)
{ }];

IOS SDK 4.3以上兼容版,需要使用AFNetworking-0.10.x版本

    AFHTTPClient *httpClient = [AFHTTPClient clientWithBaseURL:nil];
[httpClient getPath:@"http://www.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{ } failure:^(AFHTTPRequestOperation *operation, NSError *error)
{ }];

最新文章

  1. solr_架构案例【京东站内搜索】(附程序源代码)
  2. 第11章 Linux服务管理
  3. ubuntu - 中文
  4. JavaMail邮件开发
  5. 『转载』C# winform 中dataGridView的重绘(进度条,虚线,单元格合并等)
  6. ubuntu下Tomcat7的安装和配置
  7. hibernate中session
  8. hOAuth2.0认证和授权原理
  9. c# String ,String[] 和 List<String>之间的转换
  10. 探索Windows命令行系列(1):导航目录
  11. HDU 1050(搬椅子 数学)
  12. babelrc
  13. Alpha(5/10)
  14. 【ZH奶酪】如何用Python实现编辑距离?
  15. iOS项目之“返回”手势操作相关
  16. nyoj 探寻宝藏
  17. C++ 常用函数方法
  18. (转载)ios的一些知识点
  19. Mac下使用Wine安装正则表达式工具RegexBuddy 4
  20. JAVA多线程提高七:Callable与Future的应用

热门文章

  1. cordova ios --->OC 调用 js (一)
  2. .Net性能优化时应该关注的数据
  3. 【MySQL】SQL语句嵌套1
  4. yii 事物
  5. LLVM language 参考手册(译)(3)
  6. ref和out的区别,值类型和引用类型的使用
  7. html5 canvas画板
  8. Curses library not found. Please install appropriate package
  9. 实现Win7远程桌面关机和重启
  10. synchronized的重入