I'm trying to write a class method with the following header.
and the code as follows.
However, I keep getting the following warnings in the initWithPointX method
When I run the program it crashes with
I've been Googling for a Class Method example, but can't find one. Can anyone help?
This is related to my previous post NSMutableArray and Pointers for some context.
Thanks
Code:
@interface Point3D : NSObject
{
float pointX;
float pointY;
float pointZ;
}
+ (id)initWithPointX:(float)x Y:(float)y Z:(float)z;
- (float)x;
- (float)y;
- (float)z;
@end
and the code as follows.
Code:
+ (id)initWithPointX:(float)x Y:(float)y Z:(float)z
{
[super init];
pointX = x;
pointY = y;
pointZ = z;
return self;
}
- (float)x
{
return pointX;
}
- (float)y
{
return pointY;
}
- (float)z
{
return pointZ;
}
However, I keep getting the following warnings in the initWithPointX method
Code:
warning: instance variable 'pointX' accessed in a class method
warning: instance variable 'pointY' accessed in a class method
warning: instance variable 'pointZ' accessed in a class method
When I run the program it crashes with
Code:
The Debugger has exited due to signal 11 (SIGSEGV).The Debugger has exited due to signal 11 (SIGSEGV).
I've been Googling for a Class Method example, but can't find one. Can anyone help?
This is related to my previous post NSMutableArray and Pointers for some context.
Thanks