码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 定义单例的宏

时间:2015-10-13 18:35:31      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

#undef  AS_SINGLETON  
    #define AS_SINGLETON( __class ) \  
            + (__class *)sharedInstance;  
          
        #undef  DEF_SINGLETON  
        #define DEF_SINGLETON( __class ) \  
                + (__class *)sharedInstance \  
                { \  
                    static dispatch_once_t once; \  
                    static __class * __singleton__; \  
                   dispatch_once( &once, ^{ __singleton__ = [[__class alloc] init]; } ); \  
                    return __singleton__; \  
            }  

这些都是网上查找的代码。

iOS 定义单例的宏

标签:

原文地址:http://www.cnblogs.com/DWdan/p/4875086.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!