I’ve seen many other questions on this same topic but they’re not very clear to me, someone new to Objective-C.
I need a plain english explanation. ‘Coder speak’ is much too difficult for me to understand at this point in my learning.
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.
An instance method or variable applies to that instance. A class method (classes in Objective-C don’t have variables, though they can be simulated in various ways) applies to the whole class.
Consider the quintessential
Dogclass, which derives from theMammalclass (and so on up the tree of life.) A particular dog has anameand acollarand anowner–those are its properties. A particular dog may-barkor-chaseBallor-buryBoneInBackyard–those are its methods.The
Dogclass, on the other hand, has different methods. TheDogclass has a+globalPopulationand may instantiate itself with a+dogWithDNA:factory method. TheDogclass will have an+isExtinctmethod indicating whether the species as a whole is extinct (it’s not, of course.)In short: class methods affect the entire class, while instance methods affect a particular instance of a class.