Re: Beginner Question About CustomView, -drawRect: and Plotting Data.
Re: Beginner Question About CustomView, -drawRect: and Plotting Data.
- Subject: Re: Beginner Question About CustomView, -drawRect: and Plotting Data.
- From: "Michael Ash" <email@hidden>
- Date: Tue, 27 Jun 2006 11:05:59 -0400
On 6/27/06, Daniel J Farrell <email@hidden> wrote:
Hi folks,
I have a CustomView that does some NSBezierPath drawing from an array
of data point that I pass it: I'm plotting some scientific data.
At the moment the only way I can get a custom view to draw is my
placing the data inside the -drawRect: method. So my question is: How
can I make a method that will plot my data on the custom view every
time I call the method e.g. something like -drawRect:WithXData:YData: ?
You can't do this*. It's not possible because the system can ask your
view to redraw at any time, and the system certainly can't know what
kind of custom data to pass into your view. Rather than
drawRect:withXData:yData:, just do something like this:
[view setXData:xThing];
[view setYData:yThing];
[view setNeedsDisplay:YES];
Your view will need some instance variables to store the data, but so
it goes. That way when the system asks your view to redraw, it can
know what to redraw, so you won't have annoying problems with your
view being blank just because it got invalidated.
* Technically you *can* draw directly into a view by using
lockFocus/unlockFocus bracketing drawing commands, which means you
could implement such a custom draw method, but don't do this. Really,
don't do it.
Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden