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
查看全文
相关阅读:
海量数据查询关系型数据库存储大数据,要点就是:简单存储、分区分表、高效索引、批量写入
微服务架构
多租户系统架构
SaaS模式实现架构
net Core 2.1新功能Generic Host(通用主机)
深度学习与机器学习
RabbitMQ和Kafka
为什么使用框架
迅雷在P2P网络中的另类上传速度
Spring配置中的"classpath:"与"classpath*:"的区别研究(转)
原文地址:https://www.cnblogs.com/javawebsoa/p/2458446.html
最新文章
svn merge和branch
推荐!手把手教你使用Git
Git简介以及与SVN的区别
向函数中传递指针和传递指针的引用的区别
通过Spring Data Neo4J操作您的图形数据库
关于neo4j的嵌入式和驱动包模式该如何选择,还请解惑
win10 下安装 neo4j
SpringCloud-微服务的注册与发现Eureka
MyBatis连接Neo4j问题记录:mapper参数传递(节点标签作为参数)
IntelliJ IDEA启动spring boot项目出现Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
热门文章
neo4j遍历和图算法
图数据库neo4j和关系数据库的区别
neo4j中对节点关系和聚类的思考
Neo4j系列-简介及应用场景
受 SQLite 多年青睐,C 语言到底好在哪儿?
MAME 0.201 发布,重温童年的街机模拟器
”危险“的RESTRICT与GCC的编译优化(编程者对编译器所做的一个“承诺”:使用restrict修饰过的指针,它所指向的内容只能经由该指针修改)
Qt容器类的对象模型及应用(线性结构篇:对于QList来说,sharable默认是false的,但对于接下来讲的QVector来说,sharable默认是true)
SQL Server 索引中include
RabbitMQ和Kafka可靠性
Copyright © 2011-2022 走看看