Objective C playing funny, or just me?
Objective C playing funny, or just me?
- Subject: Objective C playing funny, or just me?
- From: Ruben Westerberg <email@hidden>
- Date: Wed, 10 Oct 2001 15:49:59 +1000
Hi all,
I have some code that compiles, no errors and runs. The code interprets
mouse events. The problem is the program crashes when I access the class
variables, but only in some methods.
here is the code (mostly debugging mess):
-(id)initWithComponent:(SNPComponent *)theComponent
{
// the super class gives the default @protected access to newPath and
currentElement
self = [super initWithComponent:theComponent];
newPath = [NSBezierPath bezierPathWithRect:NSMakeRect(0,0,0,0)];
//THIS WORKS, CAN ACCESS VARIABLES HERE, GET EXPECTED RESULTS
NSLog([currentComponent name]);
printf("elements is Bezier path: %d\n",[newPath elementCount]);
return self;
}
(void)mouseDownAtPoint:(NSPoint ) mPoint
{
mouseDownPoint= mPoint;
//do other stuff here. Doesn't access currentComponent
//THE SAME 2 LINES OF CODE HERE CAUSE A SIGBUS 10 ERROR
printf("elements is Bezier path: %d\n",[newPath elementCount]);
NSLog([currentComponent name]);
}
(void)mouseDraggedAtPoint:(NSPoint ) mPoint
{
mouseDownPoint= mPoint;
//do other stuff here. Doesn't access currentComponent
newPath = [NSBezierPath
bezierPathWithRect:NSMakeRect(mouseDraggedPoint.x,
mouseDownPoint.y, mouseDownPoint.x-mouseDraggedPoint.x,
mouseDraggedPoint.y-mouseDownPoint.y)];
//THE SAME 2 LINES OF CODE HERE ***DO NOT*** CAUSE A SIGBUS 10 ERROR
// AND GIVE THE EXPECTED RESULTS
printf("elements is Bezier path: %d\n",[newPath elementCount]);
NSLog([currentComponent name]);
}
(void)mouseUpAtPoint:(NSPoint ) mPoint
{
mouseDownPoint= mPoint;
//do other stuff here. Doesn't access newPath or currentComponent
//THE SAME 2 LINES OF CODE HERE CAUSE A SIGBUS 10 ERROR
printf("elements is Bezier path: %d\n",[newPath elementCount]);
NSLog([currentComponent name]);
}
@end
Does anyone know what is going on here... I am fairly new to Objective
C, is there something that i am missing? sorry if this is an obvious
mistake on my behalf...but any help would be great....
sorry for the large amount of code...
thanks
Ruben