首页 > 移动平台 > 详细

iOS 定义单例的宏

时间:2015-10-13 18:32:38      阅读:249      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!