Re: NSTextField not updated during large process
Re: NSTextField not updated during large process
- Subject: Re: NSTextField not updated during large process
- From: Koen van der Drift <email@hidden>
- Date: Mon, 01 Oct 2012 18:11:40 -0400
On Oct 1, 2012, at 5:39 PM, Koen van der Drift <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden