Singleton.m 862 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // Singleton.m
  3. // iSales-NPD
  4. //
  5. // Created by Jack on 2016/10/12.
  6. // Copyright © 2016年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "Singleton.h"
  9. #import "NotificationNameCenter.h"
  10. @implementation Singleton
  11. + (instancetype)sharedInstance {
  12. static Singleton *singleton = nil;
  13. static dispatch_once_t onceToken;
  14. dispatch_once(&onceToken, ^{
  15. singleton = [[Singleton alloc] init];
  16. });
  17. return singleton;
  18. }
  19. - (void)setGlobal_lock:(BOOL)global_lock {
  20. _global_lock = global_lock;
  21. if (global_lock) {
  22. [[NSNotificationCenter defaultCenter] postNotificationName:Lock_Permission_Notification object:nil];
  23. } else {
  24. [[NSNotificationCenter defaultCenter] postNotificationName:unLock_Permission_Notification object:nil];
  25. }
  26. }
  27. - (void)resetGlobalLock {
  28. _global_lock = YES;
  29. }
  30. @end