As above, but careful, I’m only interested in Objective-C context, so there is no point in pointing out the advantages of a singleton over a static methods.
As above, but careful, I’m only interested in Objective-C context, so there is no
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would say nothing. Singletons are often considered bad practice and this applies to Obejctive-C as well. One thing that might make singletons a better solution than class methods is that singletons are proper instances that can access instance variables, so if one needs the class to store data in ivars, singletons can be a solution. (But well, even implementing singletons often requires using static global or local variables – so strictly speaking, you can’t really avoid them entirely, at most you can reduce their number to one.)