Singleton.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. - (NSString *)homeClickedItemName {
  38. if (!_homeClickedItemName) {
  39. _homeClickedItemName = @"";
  40. }
  41. return _homeClickedItemName;
  42. }
  43. - (NSString *)deliveryString {
  44. if (!_deliveryString) {
  45. _deliveryString = @"";
  46. }
  47. return _deliveryString;
  48. }
  49. @end