Please see comment:
static void drawAnObject() {
Form *form = [[Form alloc] init];
int i;
[form randomizeCube];
glColor3f(0.0, 0.0, 0.0);
for(i = 0; i < MAX_CUBE; i++) {
glutWireCube(form->cube[i]->size);
}
}
I would rather use an accessory that I placed in the "Form" class, so I could write something like:
glutWireCube([[form cube][i] size]);
But when I try to compile this, I get the error "cannot convert to pointer type".
This is my accessor in the class "Form":
@implementation Form
- (Cube *) cube {
return *cube;
}
The variable "cube" is defined in the header file of the class "Form" as follows:
@interface Form : NSObject <NSCopying> {
Cube *cube[MAX_CUBE];
}
The following are class variables for the Cube class defined in its header file:
@interface Cube : NSObject <NSCopying> {
double size;
double positionX;
double positionY;
double positionZ;
}
... and the corresponding accessors in the implementation file (.m):
- (double) size {
return size;
}
- (void) setSize: (double) newSize {
size = newSize;
}
- (double) positionX {
return positionX;
}
- (void) setPositionX: (double) newPositionX {
positionX = newPositionX;
}
- (double) positionY {
return positionY;
}
- (void) setPositionY: (double) newPositionY {
positionY = newPositionY;
}
- (double) positionZ {
return positionZ;
}
- (void) setPositionZ: (double) newPositionZ {
positionZ = newPositionZ;
}
I would like to avoid using NSMutableArray o NSArray, as I plan to port this part of the project code to platforms without Cocoa later.
, . " " , C-Style Objective-C?