weakify/strongify 大法,的简单宏,抄至于YYKit
来源:互联网 发布:工业网络就业前景 编辑:程序博客网 时间:2024/05/19 23:01
#ifndef weakify
#if DEBUG
#if __has_feature(objc_arc)
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#else
#if __has_feature(objc_arc)
#define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
#endif
#endif
#endif
#ifndef strongify
#if DEBUG
#if __has_feature(objc_arc)
#define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
#endif
#else
#if __has_feature(objc_arc)
#define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
#endif
#endif
#endif
看了一下AFN 经常看到这样的语句
__weak__typeof(self)weakSelf =self;
AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
__strong__typeof(weakSelf)strongSelf = weakSelf;
strongSelf.networkReachabilityStatus = status;
if (strongSelf.networkReachabilityStatusBlock) {
strongSelf.networkReachabilityStatusBlock(status);
}
};
等同于导入宏后的@weakify (self)
AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
@strongify (self)
self.networkReachabilityStatus = status;
if (self.networkReachabilityStatusBlock) {
self.networkReachabilityStatusBlock(status);
}
};
- weakify/strongify 大法,的简单宏,抄至于YYKit
- @strongify以及@weakify宏命令的的使用(1)
- @weakify, @strongify
- @weakify, @strongify
- @weakify, @strongify
- MRC/ARC通用的weakify和strongify
- @weakify @strongify 对 __weak typeof(self) _self = self;的宏定义
- weakify和strongify
- @weakify, @strongify 详解
- @weakify和@strongify
- @weakify, @strongify 使用
- weakify strongify 实现
- 文MRC/ARC通用的weakify和strongify
- ObjC的Block中使用weakSelf/strongSelf @weakify/@strongify
- ObjC的Block中使用weakSelf/strongSelf @weakify/@strongify
- ObjC的Block中使用weakSelf/strongSelf @weakify/@strongify
- ObjC的Block中使用weakSelf/strongSelf @weakify/@strongify
- ObjC的Block中使用weakSelf/strongSelf @weakify/@strongify
- loadrunner---MD5加密
- Eclipse导入代码@Override和代码排列缩进出问题
- mysql 性能优化方案
- java设置响应头,解决跨域访问限制
- MySQL函数
- weakify/strongify 大法,的简单宏,抄至于YYKit
- Centos上安装eclipse
- 整理的一些好博客
- centos 下安装 php 5.6,测试方法可用
- C#设计模式00-简单工厂模式
- 15-ajax的data传参的两种方式以及乱码的解决
- Android反编译实践
- 怎样遍历Set
- 27. Remove Element