views:

37

answers:

2

when I try to run [self setNeedsDisplay:YES] in my ViewController it crashes with unrecognized selector sent to instance... is there something I'm doing wrong?

I'm using:

-(void) drawRect: (CGRect)rect {

    ///code...
}
+2  A: 

Try:

[self.view setNeedsDisplay:YES] 

You can send setNeedsDisplay: message only to UIView based classes. You can effectively override drawRect: message only for UIView based classes.

bioffe
Nope, same crash
Brodie
show us some code
bioffe
there's not much to show yet - I have tried moving [self setNeedsDisplay:YES] to viewDidLoad and the same thing happens. I get a "UIView may not respond to -setNeedsDisplay..." warning too. What I'm trying to do is make a simple drawing view. I have a bunch of CGPoints I need to draw.
Brodie
just saw your edit - i think that may be the problem. This is a ViewController I am working with
Brodie
well maybe not, because when i'm using self.view it still says, "UIView may not respond to -setNeedsDisplay"
Brodie
UIView does not have a method setNeedsDisplay: that is from NSView/AppKit. UIView has no boolean flag, just message setNeedsDisplay (no parameter)
Jason Coco
+4  A: 

-setNeedsDisplay: is a method from NSView, UIView doesn't have the (pretty much useless) boolean flag. You must call setNeedsDisplay instead. So call (from your view controller):

[[self view] setNeedsDisplay];

No parameter...

Jason Coco
yep - that was it, thanks
Brodie