#undef AS_SINGLETON#define AS_SINGLETON( __class ) \- (__class *)sharedInstance; \+ (__class *)sharedInstance;#undef DEF_SINGLETON#define DEF_SINGLETON( __class ) \- (__class *)sharedInstance \{ \ return [__class sharedInstance]; \} \+ (__class *)sharedInstance \{ \ static dispatch_once_t once; \ static __class * __singleton__; \ dispatch_once( &once, ^{ __singleton__ = [[[self class] alloc] init]; } ); \ return __singleton__; \}#undef DEF_SINGLETON_AUTOLOAD#define DEF_SINGLETON_AUTOLOAD( __class ) \- (__class *)sharedInstance \{ \ return [__class sharedInstance]; \} \+ (__class *)sharedInstance \{ \ static dispatch_once_t once; \ static __class * __singleton__; \ dispatch_once( &once, ^{ __singleton__ = [[[self class] alloc] init]; } ); \ return __singleton__; \} \+ (void)load \{ \ [self sharedInstance]; \}#import@interface Danli_yinhangkaMsg : NSObject
.h
.m
#import "Danli_yinhangkaMsg.h"
@implementation Danli_yinhangkaMsg
DEF_SINGLETON(Danli_yinhangkaMsg)
-(NSMutableArray *)data_array_YHK
{
//判断是否已经有了,若没有,则进行实例化
if (!_data_array_YHK) {
_data_array_YHK=[[NSMutableArray alloc]init];
}
return _data_array_YHK;
}
@end
http://blog.csdn.net/chaoyuan899/article/details/17524575
网友评论