2:oc中blcok的三种常见定义:
#import "HttpTool.h" typedef void(^myBlock)(Nsstring *name); @interface HttpTool () //typedef定义法 - (void)httpToolBlock:(myBlock)callBlock; // void(^block名字)(参数列表) @property (nonatomic,copy)void(^callBlock)(Nsstring *name); // 方法的block定义 //(void(^)(Nsstring *str))callBlock - (void)blockFunc:(void(^)(Nsstring *name))callBlock; @end
3:对于block中经常会注意循环引用的问题:最好的办法是使用weckself,常见写法:
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self;
1. __weak XJViewController *weakSelf = self; 2. __weak typeof(self) weakSelf = self; 3. __weak __typeof(self)weakSelf = self;
3:使用内存图来判断是否循环引用了:
:
意见反馈邮件:1415429879@qq.com 欢迎你们的阅读和赞赏、谢谢!