iOS开发笔记--一些实用的宏定义
2014-06-19 15:40
495 查看
这是在工作中常用的一些比较实用的宏定义
// 声明单件类的类方法 #define DECLARE_SINGLETON_FOR_CLASS(classname) \ + (classname*)shared##classname; // 获取单件实例的宏定义 #define GET_SINGLETON_FOR_CLASS(classname) \ [classname shared##classname] // 合成单件类 #define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \ \ static classname *shared##classname = nil; \ \ + (classname *)shared##classname \ { \ @synchronized(self) \ { \ if (shared##classname == nil) \ { \ shared##classname = [[self alloc] init]; \ } \ } \ \ return shared##classname; \ } \ \ + (id)allocWithZone:(NSZone *)zone \ { \ @synchronized(self) \ { \ if (shared##classname == nil) \ { \ shared##classname = [super allocWithZone:zone]; \ return shared##classname; \ } \ } \ \ return nil; \ } \ \ - (id)copyWithZone:(NSZone *)zone \ { \ return self; \ } \ \ - (id)retain \ { \ return self; \ } \ \ - (NSUInteger)retainCount \ { \ return NSUIntegerMax; \ } \ \ - (oneway void)release \ { \ } \ \ - (id)autorelease \ { \ return self; \ }
相关文章推荐
- iOS开发笔记--一些实用的宏定义
- iOS开发中一些实用小代码
- IOS学习笔记68 -- 开发的一些奇巧淫技
- iOS学习笔记1-开发的一些奇巧淫技
- IOS 开发中的一些实用公共方法
- iOS学习笔记34-Apple Watch两个月开发的一些收获总结
- ios开发中,比较实用的全局宏定义分享
- iOS开发中一些实用方法的总结
- iOS开发中一些实用小代码
- iOS开发笔记(Swift)-针对Swift调用PPiFlatSegmentedControl项目的一些修改
- iOS开发 - runtime运行时一些实用方法
- iOS开发笔记--宏定义的黑魔法 - 宏菜鸟起飞手册
- 关于学习ios开发的一些笔记
- IOS开发笔记之常用的宏定义
- ios开发过程中的一些笔记,不断更新中。。。
- ios开发笔记之常用库的一些整理
- iOS开发笔记--宏定义的黑魔法 - 宏菜鸟起飞手册
- ios开发中,比较实用的全局宏定义分享
- ios 开发中用到的一些宏定义
- iOS开发笔记--宏定义的黑魔法 - 宏菜鸟起飞手册