IOS block 记录
2015-07-13 15:26
344 查看
1.需要使用 @property(....,copy) 而不是其他的
2.self.request=[ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
[_request setRequestMethod:@"GET"];
__weak ASIHTTPRequest *_requestCopy = _request;
__weak RegistUserViewController *this = self;
[_request setCompletionBlock:^{
this.mobileField.enabled= YES;
this.nextStepBtn.enabled = YES;
NSInteger statusCode = [_requestCopy responseStatusCode];
NSString *result = [_requestCopy responseString];
}];
或者 直接__weak ASIHTTPRequest req = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]];
3.
对于property就用点操作符 bself.xxx
对于非property的成员变量就用->操作符 bself->xxx
最后总结,所有的这些都是围绕一点,block会retain相应的变量,我们要使用用弱引用修饰的变量。
2.self.request=[ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
[_request setRequestMethod:@"GET"];
__weak ASIHTTPRequest *_requestCopy = _request;
__weak RegistUserViewController *this = self;
[_request setCompletionBlock:^{
this.mobileField.enabled= YES;
this.nextStepBtn.enabled = YES;
NSInteger statusCode = [_requestCopy responseStatusCode];
NSString *result = [_requestCopy responseString];
}];
或者 直接__weak ASIHTTPRequest req = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]];
3.
对于property就用点操作符 bself.xxx
对于非property的成员变量就用->操作符 bself->xxx
最后总结,所有的这些都是围绕一点,block会retain相应的变量,我们要使用用弱引用修饰的变量。
相关文章推荐
- iOS导航控制器使用interactivePopGestureRecognizer导致导航栏标题可能层次错乱的问题解决
- iOS开发系列--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开发汇总
- iOS开发系列--通知与消息机制
- iOS时间格式说明
- iOS时间戳字符串NSdate转换demo
- IOS开发系列--无限循环的图片浏览器
- iOS开发系列--触摸事件、手势识别、摇晃事件、耳机线控
- IOS 第三方管理库管理 CocoaPods
- iOS开发学习准备
- iOS类别(Category)和扩展(Extension,匿名类)
- 2015最新iOS二进制打包上传流程
- iOS开发系列--数据存取
- iOS手势之 响应上下左右滑动手势
- iOS 使用 RSA 加密, 只需要公钥
- iOS判断是否有权限访问相机,相册,定位
- IOS 本地通知
- iOS开发工具——统计Crash的工具Crashlytics
- 【吐槽】MAC 和 iOS 开发貌似相差挺大的
- iOS ShareSDK分享注意事项
- ios启动动画