Question

Why can't I dereference pointers to objects or why aren't pointers to objects dereferenced?

myClass * object = [[myClass alloc]init];
[*object instanceMethod]; //Like this
[object instanceMethod]; //Instead of this

cause sending messages needs classes/objects as their receiver.

Thanks.

Était-ce utile?

La solution

The Objective-C syntax [x foo] is equivalent to C's x->foo(), and x is a pointer. Objective-C variables are always pointers; and objects are never variables -- they can only be managed through a pointer.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top