对于Http的编码统一
来源:互联网 发布:重庆外包seo找谁好 编辑:程序博客网 时间:2024/06/06 01:32
-(void)httpSample1{ /******** * self不会释放,直到block释放self才释放,因为block中有对self的强引用 *******/ HttpRequest *request = [[HttpRequest alloc] init]; [request setStrUrl:@"http://192.168.1.129:9097/api/dog/device/fence/effectiveTimes"]; [request setCompletionBlockWithType:HttpTypeGet success:^(HttpResponse *response) { self.textView.text = @"succ"; NSLog(@"current thread :%@",[NSThread currentThread]); } failure:^(HttpResponse *response) { self.textView.text = response.errorDescription; NSLog(@"error :%@",response.errorDescription); }];}-(void)httpSample2{ /******** * self先释放,strongself变为nil,block回调时不会改变strongself的成员变量值 *******/ HttpRequest *request = [[HttpRequest alloc] init]; [request setStrUrl:@"http://192.168.1.129:9097/api/dog/device/fence/effectiveTimes"]; __weak FrameworkDemoVC *weakSelf = self; [request setCompletionBlockWithType:HttpTypeGet success:^(HttpResponse *response) { __strong FrameworkDemoVC *strongSelf = weakSelf; strongSelf.textView.text = @"succ"; NSLog(@"current thread :%@",[NSThread currentThread]); } failure:^(HttpResponse *response) { __strong FrameworkDemoVC *strongSelf = weakSelf; strongSelf.textView.text = response.errorDescription; NSLog(@"error :%@",response.errorDescription); }];}/****!!!!!!!!!!!!!推荐用法 推荐用法 推荐用法 推荐用法 推荐用法 推荐用法****/-(void)httpSample3{ /******** * 和httpSample2一个效果,故实际使用时使用httpSample3即可,无需再对weakSelf进行一次强引用 *******/ HttpRequest *request = [[HttpRequest alloc] init]; [request setStrUrl:@"http://192.168.1.129:9097/api/dog/device/fence/effectiveTimes"]; __weak FrameworkDemoVC *weakSelf = self; [request setCompletionBlockWithType:HttpTypeGet success:^(HttpResponse *response) { weakSelf.textView.text = @"succ"; NSLog(@"current thread :%@",[NSThread currentThread]); } failure:^(HttpResponse *response) { weakSelf.textView.text = response.errorDescription; NSLog(@"error:%@",response.errorDescription); }];}
阅读全文
0 0
- 对于Http的编码统一
- ipmi对于统一硬件管理的意义
- struts2 的统一编码设置
- eclipse 的编码统一设置
- eclipse统一编码的方式
- 统一Eclipse的编码风格
- 编码统一
- 对于编码的初步认识
- 通过Filter进行统一编码的实现
- Netbeans统一UTF-8编码的方法
- linux下mysql的编码统一
- jsp_ajax乱码,注意编码方式的统一
- Netbeans统一UTF-8编码的方法
- javaJSP实现页面的统一编码
- 汉字的统一与存储编码
- 对于Http的简单理解
- angular2实现统一的http请求头
- Http协议的编码
- Spring MVC入门
- 关于Date类型的常见问题及处理方法
- 476. Number Complement
- Oracle数据库分区表
- javaIO(4):Reader,InputStreamReader和FileReader源码分析
- 对于Http的编码统一
- python中的dir()和__dict__
- 批量操作之多选
- bootanimation.zip 替换/更换 黑屏
- 策略模式Strategy(对象行为型)
- 广播的类型————拦截有序广播
- AlertDialog弹框apk版本升级
- 【LeetCode】 73. Set Matrix Zeroes
- Mysql 创建数据库、用户、授权、导入数据