Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: a question about "->"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a question about "->"



> the -> operator is the same operator as it is in C, it dereferences a
> pointer, and then accesses a value from a struct/union:

I'm sorry..  I am afraid I don't really understand what any of that means...

Dereferences a pointer?  So-- meaning when I do:

Foo *foo = [[Foo alloc] init];

I can somehow do "->" on foo and it will no longer be connected to the type
Foo?

...

I still don't quite get struct/unions --  I mean, I get their 'text book
definition'.  But I don't get their practical usage...  When to use them, why,
etc..  It seems like if they are only data storage, why not use an array /
dictionary?  What is the real benefit?

Thanks.

Patrick J. Collins
http://collinatorstudios.com


On Fri, 2 Jul 2010, Thomas Davie wrote:

>
> On 2 Jul 2010, at 09:59, Patrick J. Collins wrote:
>
> > Hi everyone,
> >
> > I was looking over an article on properties:
> > http://www.cocoacast.com/?q=node/103
> > 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:
> >
> > instance->property_name
> >
> > 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?
>
 _______________________________________________
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

References: 
 >a question about "->" (From: "Patrick J. Collins" <email@hidden>)
 >Re: a question about "->" (From: Thomas Davie <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.