runxinzhi.com
首页
百度搜索
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
相关阅读:
ArrayList和HashTable妙用一
面向过程,面向对象的深入理解一
jquery中限制部分字段不能输入
MySql用int存储时间
android绑定sqlite数据库与程序一起发布
extjs 4和jquery整合
jQuery.support 的实现方式
常用JavaScripts方法
SVN错误信息大全
android封装的menu自定义菜单列表
原文地址:https://www.cnblogs.com/javawebsoa/p/2458446.html
最新文章
C语言全排列
C语言结构体
C语言结构体参数传递
Mac苹果电脑单片机开发
Mac如何下载软件
转发:漫谈数据库索引
使用.NET中的XML注释(一) XML注释标签讲解
SessionID的传送
使用.NET中的XML注释(二) 创建帮助文档入门篇
诗篇欣赏 锦瑟
热门文章
正式迁居这里
当关闭子窗口时刷新父窗口
面向对象的深入理解三
Winform基础
ArrayList和HashTable妙用二
多态
面向过程,面向对象的深入理解二
winform中常用的控件
文件管理File类
C#中其它一些问题的小节
Copyright © 2020-2023
润新知