Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh view with display and setNeedsDisplay not working
    text
    copied!<p>I am having problems updating my customView object during simulation. The window pops up after the simulation is done. I would like it to update itself during the simulation. For this I use <code>setNeedsDisplay:YES</code> and I have also tried <code>display</code>. None of this works for me however. Does anyone have an idea how I should get this working? As you can see below I have tried to create a new thread for the updating as well as using NSOperations. Grateful for help!</p> <pre><code>//Run simulation for (int iteration=0; iteration&lt;numberOfIterations; iteration++){ //NSInvocationOperation *update = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(updatePopulation) object:nil]; //NSInvocationOperation *draw = [[NSInvocationOperation alloc] initWithTarget:view selector:@selector(redraw) object:nil]; //[draw addDependency:update]; //[queue addOperation:update]; //[queue addOperation:draw]; [NSThread sleepForTimeInterval:0.01]; //to make it easer to see.. [self updatePopulation]; //[view redraw]; [NSThread detachNewThreadSelector:@selector(redraw) toTarget:view withObject:nil]; //[self performSelector:@selector(updatePopulation) withObject:nil afterDelay:1]; //[view performSelector:@selector(redraw) withObject:nil afterDelay:1]; //Save segregation if (iteration%(numberOfIterations/100) == 0) { printf("hej\n"); } } </code></pre> <p>in my viewer class:</p> <pre><code>- (void) redraw { //[self setNeedsDisplay:YES]; [self display]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload