Singleton.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. - (void)dealloc {
  12. [[NSNotificationCenter defaultCenter] removeObserver:self];
  13. }
  14. + (instancetype)sharedInstance {
  15. static Singleton *singleton = nil;
  16. static dispatch_once_t onceToken;
  17. dispatch_once(&onceToken, ^{
  18. singleton = [[Singleton alloc] init];
  19. [[NSNotificationCenter defaultCenter] addObserver:singleton selector:@selector(handleLogin:) name:User_LoginOK_Notification object:nil];
  20. });
  21. return singleton;
  22. }
  23. - (void)setGlobal_lock:(BOOL)global_lock {
  24. _global_lock = global_lock;
  25. if (global_lock) {
  26. [[NSNotificationCenter defaultCenter] postNotificationName:Lock_Permission_Notification object:nil];
  27. } else {
  28. [[NSNotificationCenter defaultCenter] postNotificationName:unLock_Permission_Notification object:nil];
  29. }
  30. }
  31. - (void)resetGlobalLock {
  32. _global_lock = NO;
  33. }
  34. - (void)handleLogin:(NSNotification *)notification {
  35. self.currentOrderIsMerged = NO;
  36. }
  37. @end