drawRect not being called

I have a Class View:UIView, inheriting from class Controller:NSObject. Class View is responsible for the view and the drawRect method is overridden there, to draw what I want.

Now I want to call setNeedsDisplay from class Controller, which doesn't know about View yet. So I have told it via @class View, that there is a class View, defined an IBOutlet of type View and made the connection in the Interface Builder.

There, I have an Object of Class Controller, and its Outlet referencing to View.
Still, when calling setNeedsDisplay on the outlet within the Controller class, drawRect is not called.

I can call drawRect from the View class without any problems wrong. I even checked the Outlet for being nil, and it also has its accessors synthesized.

//here I want the View to redraw itself
[viewController setNeedsDisplay];

}

=========
In Interface Builder I have connected the Outlets, one from GameField to GameView and the other vice versa.
Now the GameView accesses the data in GameField correctly, theres no problem. But I cant access the GameView from the GameField - drawRect is not called. Why not? I have done everything in the same way-.... one works, the other doesn't........

It's a bit confusing calling your GameView instance viewController, because there's a class called UIViewController. But that shouldn't affect how it works.

Are you sure your drawRect: method is correct? If you get it wrong it'll just call UIView's default implementation and your code will never get called, and there will be no compiler warning. It should be in the form of:

Code:

- (void)drawRect:(CGRect)rect

Or did you just shorten it to post here?

Also remember that setNeedsDisplay doesn't call drawRect: immediately, it waits until it returns to the run loop. If you're doing anything odd like running in your own loop it'll never get called.