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
查看全文
相关阅读:
【MYSQL】SQL 的join 区别
【Django】Django model与数据库操作对应关系(转)
【Mysql】复制表结构+数据(转)
【Django】Python web开发:几个模板系统的性能对比(转)
【Mysql】Mysql关键字
【Mysql】MySQL与Oracle的大小写问题
Linux常用操作
执行程序的两种方式
Django框架的安装与使用
web介绍
原文地址:https://www.cnblogs.com/javawebsoa/p/2458446.html
最新文章
使用C#实现FTP的文件上传和下载【转】
转:设置图片透明的四种方法
(转)FTP操作类,从FTP下载文件
(转)教你实现Winform窗体的四边阴影效果
(转)C#/.NET主线程与子线程之间的关系
关于C# WinForm 边框阴影窗体(一)
C#中WinForm程序退出方法技巧总结(转)
Python之路----各类推导式
Python之路----列表推导式和生成器的表达式
Python之路----生成器函数进阶
热门文章
Python之路----迭代器与生成器
python之路——初识函数
python基础七--集合
python基础八---文件操作
python基础六
python基础五--dict
python基础四
【MYSQL】解决Mysql直接登录问题(删除匿名用户)(转)
【PHP】linux+php5.1.6+mysql5.0.2+apache2.0.55安装配置说明(转)
【YII】Yii入门
Copyright © 2011-2022 走看看