سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top