I want to create a class in objective-c with its methods, so that for accessing the data I don’t want to instantiate the class. how can I do it?
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.
You may use singleton pattern, check this question.
Like this:
Or if you want to just access methods, you may use factory methods (those with +, not with -)
UPDATE:
You may add a property to
appDelegateand get
appDelegatefrom almost any place like:Note, that you’ll need to
#importyour UIViewController subclass and yourappDelegate.hto make autocomplete work and sometimes avoid warnings.