// MyCommon.h: @interface MyCommon class MyCommon : NSObject { int user; }; @property(assign) int user; + (MyCommon *)singleton; @end // MyCommon.m: @implementation MyCommon static MyCommon * MyCommon_Singleton = nil; + (MyCommon *)singleton { if (nil == MyCommon_Singleton) { MyCommon_Singleton = [[MyCommon_Singleton alloc] init]; } return MyCommon_Singleton; } @end The MyCommon singleton is then used anywhere in my application as follows: int user = [MyCommon singleton].user;


相关文章:

  • 2022-12-23
  • 2021-08-08
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-21
  • 2022-03-06
  • 2022-02-05
  • 2021-12-26
  • 2021-11-17
  • 2022-02-16
相关资源
相似解决方案