| Sign In/My Account | View Cart |
| Article: |
The Objective-C Language | |
| Subject: | Comments | |
| Date: | 2004-08-30 11:40:19 | |
| From: | hEADcRASH | |
|
I could see how the line "They are analagous to global variables in C" might cause a lot of confusion for beginning programmers (especially those not fully versed in C). It's all about the scope, baby!
|
||
Showing messages 1 through 1 of 1.
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.