Can anyone please explain what is the reason to prevent an instance in singleton.
I saw that some says to do like below
private override init (){
}
but it works fine if we do this or not.
Can anyone please explain what is the reason to prevent an instance in singleton.
I saw that some says to do like below
private override init (){
}
but it works fine if we do this or not.
I'm not sure what do you mean by this question, if you're asking why is the initialiser private then it comes from definition of Singleton design pattern. Initialiser needs to be private to make sure nobody can crate another instance of your singleton.