Note that there are some explanatory texts on larger screens.

plurals
  1. PONSOperation synchronization problem
    text
    copied!<p>I am struggling to find a way to synchronize operation on IPhone app. I have three main NSOperation.</p> <pre><code> NSInvocationOperation *showSpinner = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(spinnerOn:) object:YES]; NSInvocationOperation *reloadDatasource = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(reloadDatasource) object:nil]; NSInvocationOperation *hideSpinner = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(spinnerOn:) object:NO]; // Add dependency [reloadDatasource addDependency:showSpinner]; [hideSpinner addDependency:reloadDatasource]; [self.queue addOperation:showSpinner]; [self.queue addOperation:reloadDatasource]; [self.queue addOperation:hideSpinner]; </code></pre> <p>I can see that the three operations are correctly started in sequence. However, as you can imagine, the first operation create a UIView and attach it on top, while the last one should remove it. </p> <p>It happens that graphically speaking the operations happens at once on the screen. So I can see the table already loaded, while the spinner is on screen, or other strange unsynchronized things.</p> <p>I understood that change on the graphic side happen on the main thread. So I am asking how can I modify the code to do what it is supposed to do. Which is: create spinner, load data, and remove spinner ? Is there a common way to separate graphic operation and data operation ? For example create two distinct operation. </p> <p>thanks</p>
 

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