Singleton in iOS Objective C doesn't prevent more than one instance

后端 未结 9 1551
长情又很酷
长情又很酷 2020-11-29 08:53

I know there are several threads on this, but none answer my questions.

I\'ve implemented my singleton class like this (being aware of the controversy about singleto

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 09:17

    Calling alloc / init to get a second instance of a Singleton class is considered a blatant programming error. To avoid this kind of programming error, you don't write complicated code to prevent it, you do code reviews and tell off everyone trying to do it, as you would with any programming error.

提交回复
热议问题