iOS项目中兼容ARC与非ARC的一些宏定义
2013-12-26 17:51
363 查看
// // ARCMacros.h // #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
参考:http://raptureinvenice.com/arc-support-without-branches/
相关文章推荐
- iOS开发中混合使用ARC和非ARC项目
- iOS学习之在ARC项目中使用非ARC文件:ARC forbids explicit mess...
- iOS-为方便项目开发在pch添加一些常用宏定义
- iOS-ARC项目使用非ARC文件 MRC项目使用ARC文件
- ios开发答疑录系列---(四)OS开发中混合使用ARC和非ARC项目
- IOS ARC项目使用非ARC文件 MRC项目使用ARC文件
- iOS-为方便项目开发在pch加入一些经常使用宏定义
- Xcode项目兼容ARC和非ARC代码
- 让ios项目同时支持ARC和非ARC
- 【iOS开发系列】单例模式宏(兼容ARC和非ARC)
- iOS 中 ARC 项目 兼容 MRC
- iOS ARC与非ARC在一个项目中同时使用
- IOS ARC项目使用非ARC文件 MRC项目使用ARC文件
- 完美单例宏定义(兼容ARC和MRC),项目中可以直接使用
- IOS ARC项目使用非ARC文件 链接
- IOS ARC和非ARC文件混用
- 兼容iOS 10 ,升级xcode8出的一堆问题的解决方案,以及一些适配.
- IOS 项目整合百度地图三方的时候遇到的一些问题
- ios开发,工程中混合使用ARC和非ARC (转)
- 论坛源码推荐(4月28日):列表项目的波浪效果 兼容iOS 6与iOS 7的自定义导航条