Question:
What’s the difference between a class method and an instance method?Are instance methods the accessors (getters and setters) while class methods are pretty much everything else?
Best Answer:
Like most of the other answers have said, instance methods use an instance of a class, whereas a class method can be used with just the class name. In Objective-C they are defined thusly:NSString
‘s +stringWithFormat:
or NSArray
‘s +arrayWithArray:
. An instance method would be NSArray
‘s -count
method.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review