advertisement

Article:
  The Objective-C Language
Subject:   Comments
Date:   2004-09-04 15:38:20
From:   eflexx
Response to: Comments

Class methods are methods that can be called on a class without any instance objects being created. They can be used without creating instances of the class. If you are familiar with the Java programming language, this is analgous to a "static" method.


Instance methods on the other hand are methods that involve a specific instance of the class, and therefore require an instance to exist to be used.


Methods like alloc shown above need to be class methods since instances have to be created even when you have no instances created yet; ie. when there are no instances, you cannot call instance methods.


An example of an instance method might be if you had a class Door with a method "open." open is an instance method because it needs only involve the instance of Door in question. In other words, you dont want to have to open all Doors at once every time you call open, so you call it on the Doors you want opened.


Hope that helps.