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
查看全文
相关阅读:
centos 安装python3.6 简易安装过程
包装类型
剑指offer二叉树中和为某一值的路径
剑指offer 捡绳子
按位与的技巧
SpringBoot 登录拦截功能的实现
AIO实现简单http服务器
真题-数的分解
重建二叉树
旋转数组的最小数字
原文地址:https://www.cnblogs.com/javawebsoa/p/2458446.html
最新文章
python-django中使用事务以及小坑
python-django中的APPEND_SLASH实现
python-join方法
数据库中插入记录
AJAX
Latex使用整理
人脸关键点标注
php周计划1
CSS 常用基本功能整理
php简单框架的应用实例
热门文章
php之登录功能实现。
eclipse for php现有项目不能导入问题
php之jquery
Python中常见的内置类型
Python中 type、object和class关系
Python Selenium常见用法介绍
把Python打包成可执行文件
Python正则表达式
CentOS使用virtualenv搭建独立的Python环境-python虚拟环境
linux替换目录下所有文件中的某字符串
Copyright © 2011-2022 走看看