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 17:39:38 -0400
On Oct 1, 2012, at 8:59 AM, Koen van der Drift <email@hidden> wrote:
> Ok, I decided to use NSOperation(Queue) as it is generally recommended
> over performSelectorXXX to be a more modern API, and have been reading
> a bit about it. In Hillegass' Cocoa book, he uses processQueue
> addOperationWithBlock, in other examples on the webs, people make
> subclasses of NSOperation to put their tasks in. What's the difference
> between these two appraches (if any)?
Playing around with NSOperationQueue, and I implemented it as follows. I use this method to do some calculations, and store the results in a table.
- (void)doMyTask
{
[self cleanUp]; // clear the NSTableView
NSOperationQueue *myQueue = [[NSOperationQueue alloc] init];
[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
}
This works, and is faster than before, but if I run this several times in a row, at one point I get a crash, somewhere in the parseData routine. It could happen after ten times, or even after one time. But always at the same point:
[self willChangeValueForKey:@"myArray"];
[self.myArray addObject: newObject];
[self didChangeValueForKey:@"myArray"];
This is called during the parse, when I update the myArray property as a result of the parsing.
Any idea what could be going on?
- 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