The following UIImageView
is drawn on my ViewController's window only after I exit the
-(void)playOn:(UIViewController*) currentViewController
method. Why is that? How can I make it so that I can draw on my ViewController from inside that method while that method is executing?
CellPainter.m
-(void)paintGoodCellonViewController:(UIViewController*)playingViewController
{
int x = 32*(xAxis - 1);
int y = 384 - (32* yAxis);
UIImageView* myImageView = [[UIImageView alloc] initWithImage:goodCell];
myImageView.frame = CGRectMake(x,y, 32, 32);
[playingViewController.view addSubview:myImageView];
}
Game.m
-(void)playOn:(UIViewController*) currentViewController
{
[currentPainter paintGoodCellonViewController:currentViewController];
while(!self.stopButtonPressed)
{
// code...
}
}
MyViewController.m
- (IBAction)enterButtonPressed:(UIButton *)sender
{
[currentGame performSelectorInBackground:@selector(playOn:) withObject:self];
}
- (IBAction)giveUpButtonPressed:(UIButton *)sender
{
currentGame.stopButtonPressed = YES;
}