Farini
Farini

Reputation: 933

drawRect, wait for order

How do I get drawRect to wait for for the ViewController to give the order to draw When the ViewController actually wants.

I'm drawing a chart that depends od the viewControllers array to draw itself.

The UIView is drawing but it's not waiting for all variables to take place. i did on ViewController:

[self.chartView setNeedsDisplay];

and the ChartView (UIView) i got the following:

NSArray *numbersForLine = [self.delegate WhatsTheArray:self];
NSLog(@"numbersForLine in Chartview: %@", numbersForLine);

After I get my array of points to draw with, I call the method above. The problem is that it just ignores the array and draws whatever it has to draw. It doesn't wait for the ViewController to send the array.

Is there any way I can get it to wait for the ViewController to pass that array and then drawRect ? Or is there any other method of implementation other then the delegate to do what I want ?

Upvotes: 0

Views: 107

Answers (1)

cocoakomali
cocoakomali

Reputation: 1356

Why don't you have a property of the array object in the ChartView class to be accessed from the ViewController. Then,

self.chartView.inputArray = array;
[self.chartView setNeedsDisplay];

Upvotes: 1

Related Questions