当前位置:首页 > 操作系统 > Ios

iOS 定义单例的宏

            #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__;   
            }  

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

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


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!