为何GCD中的block不需要用weakself?
分类:
移动开发 时间:
2015-07-15 10:56:02
阅读次数:
351
OC 中 全局宏定义#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self;用法如下:WS(weakself)[self.tableView addHeaderWithCallback:^{[weakself requestMember...
分类:
编程语言 时间:
2015-07-07 00:44:33
阅读次数:
201
我们都知道在防止如block的循环引用时,会使用__weak关键字做如下定义:__weak typeof(self) weakSelf = self;后来,为了方便,不用每次都要写这样一句固定代码,我们定义了宏:#define WeakSelf __weak typeof(self) weakSelf = self;之后,我们可以比较方便的在需要的地方:WeakSelf;
...
[weakSelf...
分类:
移动开发 时间:
2015-07-03 12:25:31
阅读次数:
279
#import "FourViewController.h"
#import "View+MASAdditions.h"
#import "FiveViewControllerr.h"
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self;
#define SCREEN_WIDTH [UIScreen mainScreen...
分类:
移动开发 时间:
2015-07-01 12:25:27
阅读次数:
202
http://rocry.com/2012/12/18/objective-c-type-of/?utm_source=tuicool在不久前看AFNetworking的源码时候发现了这么一句:12345678910// 不知道这行代码的使用场景的同学你该去自习看看ARC的注意事项和Block的使用...
分类:
其他好文 时间:
2015-06-25 21:10:59
阅读次数:
98
闭包定义闭包参数闭包返回值闭包简化 - 尾随闭包闭包的循环引用weak var weakSelf = selfdemo("zhangsan") { (_) -> Int in println(weakSelf?.view.backgroundColor) return 20}
分类:
其他好文 时间:
2015-06-24 23:44:20
阅读次数:
168
本算法实现了微信的语音连播功能:即自动读取本条之后的未读语音消息;连播一般都是一条播放完成,在接着播放下一条。
- (void)clickCellVoice:(VMessageEntity *)model
{
__weak
VChatsViewController *weakSelf =
self;
if ([self.keyBoardView
isFirstRes...
分类:
微信 时间:
2015-05-27 10:20:29
阅读次数:
367
__weak typeof(self)weakSelf=self; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ ...
分类:
其他好文 时间:
2015-05-26 20:44:37
阅读次数:
125
#import "ViewController.h"#import "Masonry.h"#define kWeakSelf(weakSelf) __weak typeof(self)weakSelf = self#define WS(weakSelf) __weak __typeof(&*sel....
分类:
移动开发 时间:
2015-05-26 18:02:52
阅读次数:
184
在不久前看AFNetworking的源码时候发现了这么一句:
1
2
3
4
5
6
7
8
9
10
// 不知道这行代码的使用场景的同学你该去自习看看ARC的注意事项和Block的使用了
// AFNetworking的写法
__weak __typeof(&*self)weakSelf = self;
// 我之前一直这么写的
__weak __typeof...
分类:
其他好文 时间:
2015-04-28 18:29:55
阅读次数:
186