On 2 Jul 2010, at 09:59, Patrick J. Collins wrote:
> Hi everyone,
> I was looking over an article on properties:
> and I noticed the notation "->", which I am a bit unfamiliar with. It looks as
> though it is a way to access the getter method from an object such as:
> Atleast, that's what I think is going on.. I have always done this as:
> [instance property_name]
> .. However, I tried doing the -> way in a test command-line tool and when I
> did, I got a warning that an instance variable was protected and it will be a
> hard failure in the future..
> 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?
the -> operator is the same operator as it is in C, it dereferences a pointer, and then accesses a value from a struct/union:
a->b; is equivalent to (*a).b;
In your case, it's not accessing the property (no setter or getter is called when using it), instead it's accessing the ivar directly. In the context of objective-c it's a good indication of at very least a style issue, and sometimes a bug. You in general, should stick to using the property accessor methods, even when within your own class, that way, your abstraction barrier remains in place.
Tom Davie _______________________________________________
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