singleton in objective c

后端 未结 5 722
孤街浪徒
孤街浪徒 2021-01-22 08:56

I saw a singleton example on objective-c book. However, I don\'t know if there is difference of meaning of \'singleton\' definition between objective-c and other langs. Can this

5条回答
  •  执念已碎
    2021-01-22 09:56

    There is no language support for singletons, but you can do it by hand. Look at the singleton example here. It doesn't look like it is thread-safe, though. I would allocate the object in +initialize instead of +sharedManager.

提交回复
热议问题