• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSView puzzle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView puzzle


  • Subject: Re: NSView puzzle
  • From: Andy Lee <email@hidden>
  • Date: Thu, 9 Oct 2008 16:27:11 -0400

Are you retaining str when the view is initialized?

--Andy

On Oct 9, 2008, at 4:17 PM, DKJ wrote:

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 (email@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSView puzzle
      • From: DKJ <email@hidden>
References: 
 >NSView puzzle (From: DKJ <email@hidden>)

  • Prev by Date: NSView puzzle
  • Next by Date: Inconsistent HTML text size in TextField
  • Previous by thread: NSView puzzle
  • Next by thread: Re: NSView puzzle
  • Index(es):
    • Date
    • Thread