Am Jul 2, 2010 um 10:59 AM schrieb Patrick J. Collins:
> So obviously I am not understanding exactly what "->" is... From that error,
> it seems like it's just a way to access an instance variable from within an
> class----- but... why would you need to do self->var_name ? you should just be
> able to do var_name by itself.. Right?
You can only do var_name by itself if you are in a method of that class, and you have a "self". You can declare a function between the @implementation and @end which will be allowed to look at the instance variables of an object of that class, but since it is a free-floating function, and not a method that always must be called on an object, you don't have a self, so must tell the compiler what variable points to the object so you can call a method on it.
From your other replies it seems as if you're not yet comfortable with pointers. You may want to look at my tutorial <http://www.masters-of-the-void.com>, particularly the chapters, particularly chapter 6, "What is memory".
It doesn't explicitly cover the -> operator (which is an oversight I'll have to fix quickly), but it does cover the * operator and the "." operator, and after all,
foo->bar
is essentially another way of writing
(*foo).bar
so you should get by with the knowledge you get there.
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden