Depending on which runtime (32-bit or 64-bit) and whether you declare the instance variables (size
and point
) explicitly or have them synthesized by the runtime, you may be able to access them directly as in array[0][0]->size
. This is not a good idea however. It will break on modern runtimes and is very much not the Objective-C way and breaks encapsulation by publicly exposing implementation details of the class.
In Objective-C 2.0, the correct practice is to declare a property for each attribute that you want to be puclically visible. Add the following to Ball
's @interface
declaration:
@property (assign) int size;
@property (assign) CGPoint point;
And in the @implementation
block of Ball
:
@synthesize size;
@synthesize point;
You can now access size like ((Ball*)array[0][0]).size
. The cast is required for the compiler to recognize the dot notation as a property access. It is not required if you use the accessor methods (which are automatically generated by @synthesize
): [array[0][0] size]
.