On Oct 1, 2012, at 5:39 PM, Koen van der Drift <koenvanderdr...@gmail.com> 
wrote:

>    [myQueue addOperationWithBlock:^(void)
>    {
>        [self parseData];      // calculate the new data and update the model
>       }];
> 
> // now tell everyone we're done
>    [self finishedTask];               // update the NSTableView and the UI


More confusion...
 
So, [self parseData] creates a new array which is shown in a table (bound to 
the resulting NSArray), but also needs to update another view. The table gets 
updated, but the other view not. As it turns out, once [self finishedTask] gets 
called, the array is still empty. I guess because the parsing is still going on 
in another thread. 

I solved it as follows by adding another operation on the mainQueue inside the 
first queue:

- (void)doMyTask 
{
   [self cleanUp]; 

   NSOperationQueue    *myQueue = [[NSOperationQueue alloc] init];
        
   [myQueue addOperationWithBlock:^(void)
   {
       [self parseData];        // calculate the new data and update the model

        [[NSOperationQueue mainQueue] addOperationWithBlock:^(void)
        {
                 [self finishedTask];           // update the NSTableView and 
the UI
        }];
   }];
}

Is that a correct approach?


- Koen.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to