Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define interfaceSingleton(name) +(instancetype)share##name
- #define implementationSigleton(name) \
- + (instancetype)share##name { \
- name *instance = [[self alloc] init]; \
- return instance; \
- } \
- static name *_instance = nil; \
- + (instancetype)allocWithZone:(struct _NSZone *)zone { \
- static dispatch_once_t onceToken; \
- dispatch_once(&onceToken, ^{ \
- _instance = [[super allocWithZone:zone] init]; \
- }); \
- return _instance; \
- } \
- - (id)copyWithZone:(NSZone *)zone { \
- return _instance; \
- } \
- - (id)mutableCopyWithZone:(NSZone *)zone { \
- return _instance; \
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement