I'm having trouble with a subclass of NSView.

In the code below, the variable str is an NSString set to a constant string when the view is initialised. During initialisation the NSPoint variable click is set to 0,0.

When the view first displays, str is drawn correctly in the lower-left corner, just as you would expect. But when I click in the view, I get a bad access error. The error occurs when str is told to draw itself for the second time, in the line I've marked with ***.

I can't understand what could be happening here. According to the debuggerer, str, click, and dict all have valid values at that point.


=== CODE ===

- (void)drawRect:(NSRect)rect {
        
        NSImage *board = [[NSImage alloc] initWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"chessboard" ofType:@"tiff"]];
        
        [board drawInRect:[self bounds]
                         fromRect:NSZeroRect
                        operation:NSCompositeSourceOver
                         fraction:0.5];
        
***     [str drawAtPoint:click withAttributes:dict];
}

- (void)mouseDown:(NSEvent *)ev {
        
        click = [self convertPoint:[ev locationInWindow] fromView:nil];
        [self display];
}

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to