zoukankan
html css js c++ java
ARC专题:编写兼容ARC(自动引用计数) 和 nonARC(非自动引用计数)的通用代码
下面这段宏可以解决这个问题,而不用同时编写2套代码
写法用传统的non-ARC写法
http://raptureinvenice.com/arc-support-without-branches/
// // ARCMacros.h // InnerBand // // For an explanation of why these work, see: // // http://raptureinvenice.com/arc-support-without-branches/ // // Created by John Blanco on 1/28/12. // Rapture In Venice releases all rights to this code. Feel free use and/or copy it openly and freely! // // NOTE: __bridge_tranfer is not included here because releasing would be inconsistent. // Avoid it unless you're using ARC exclusively or managing it with __has_feature(objc_arc). // #if !defined(__clang__) || __clang_major__ < 3 #ifndef __bridge #define __bridge #endif #ifndef __bridge_retain #define __bridge_retain #endif #ifndef __bridge_retained #define __bridge_retained #endif #ifndef __autoreleasing #define __autoreleasing #endif #ifndef __strong #define __strong #endif #ifndef __unsafe_unretained #define __unsafe_unretained #endif #ifndef __weak #define __weak #endif #endif #if __has_feature(objc_arc) #define SAFE_ARC_PROP_RETAIN strong #define SAFE_ARC_RETAIN(x) (x) #define SAFE_ARC_RELEASE(x) #define SAFE_ARC_AUTORELEASE(x) (x) #define SAFE_ARC_BLOCK_COPY(x) (x) #define SAFE_ARC_BLOCK_RELEASE(x) #define SAFE_ARC_SUPER_DEALLOC() #define SAFE_ARC_AUTORELEASE_POOL_START() @autoreleasepool { #define SAFE_ARC_AUTORELEASE_POOL_END() } #else #define SAFE_ARC_PROP_RETAIN retain #define SAFE_ARC_RETAIN(x) ([(x) retain]) #define SAFE_ARC_RELEASE(x) ([(x) release]) #define SAFE_ARC_AUTORELEASE(x) ([(x) autorelease]) #define SAFE_ARC_BLOCK_COPY(x) (Block_copy(x)) #define SAFE_ARC_BLOCK_RELEASE(x) (Block_release(x)) #define SAFE_ARC_SUPER_DEALLOC() ([super dealloc]) #define SAFE_ARC_AUTORELEASE_POOL_START() NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; #define SAFE_ARC_AUTORELEASE_POOL_END() [pool release]; #endif
查看全文
相关阅读:
学习进度表
数据结构思维导图
数据结构笔记(树与二叉树)
图片链接缝隙(a于img) mn
如何用div实现(滑动条)侧边导航栏 mn
去除Linux文件中的注释行和空行 mn
高度塌陷 mn
初入HTML5
bcp命令详解转载
windows 下andriod 开发环境的搭建
原文地址:https://www.cnblogs.com/javawebsoa/p/2458446.html
最新文章
JPEG解码:反zig_zag变换
JPEG解码:反DCT变换(三)
JPEG解码:状态控制模块
JPEG解码:反DCT变换(四)
使用nvm快速搭建 Node.js 开发环境
用systemJS+karma+Jasmine+babel环境去编写简单的ES6工程
认识docker及常用的API
前端工程化
npm包管理器那些事
同源策略
热门文章
初始化一个react项目
条件注释判断浏览器
Nginx反向代理和负载均衡
JS判断浏览器iOS(iPhone)、Android手机移动端
(转载)研究openvswitch的流量模式
(原创)openvswitch实验连载1fedora 17下安装openvswitch
(原创)fedora 17安装KVM虚拟机
(原创)鸟哥linux学习script shell相关笔记
(原创)openvswitch实验连载2cisco模拟器IOUWeb安装及网络环境配置
讲座笔记
Copyright © 2011-2022 走看看