Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #define interfaceSingleton(name) +(instancetype)share##name
  2.  
  3. #define implementationSigleton(name) \
  4. + (instancetype)share##name { \
  5. name *instance = [[self alloc] init]; \
  6. return instance; \
  7. } \
  8. static name *_instance = nil; \
  9. + (instancetype)allocWithZone:(struct _NSZone *)zone { \
  10. static dispatch_once_t onceToken; \
  11. dispatch_once(&onceToken, ^{ \
  12. _instance = [[super allocWithZone:zone] init]; \
  13. }); \
  14. return _instance; \
  15. } \
  16. - (id)copyWithZone:(NSZone *)zone { \
  17. return _instance; \
  18. } \
  19. - (id)mutableCopyWithZone:(NSZone *)zone { \
  20. return _instance; \
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement