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: Fri, 12 Oct 2012 18:55:31 -0400
Man, I thought I had this all working, and after a few days of doing other stuff, it is back to my original issue. I am now updating my textfield as follows, so no matter from where it is called, it will always be updated on the main thread:
- (void)updateStatus: (NSString *)status
{
NSLog(@"%@", status);
[self performSelectorOnMainThread:@selector( updateStatusWrapper:) withObject: status waitUntilDone: YES];
}
-(void)updateStatusWrapper: (NSString *) status
{
self.progressStatus = status;
}
Again, all the logs get displayed, so I know updateStatus: is called, but again, in the parseData part, the string is not updated. For whatever reason, updateStatusWrapper: doesn't get called. I also tried YES and NO for waitUntilDone.
Any ideas what I am (still) missing?
- Koen.
On Oct 1, 2012, at 6:39 PM, Koen van der Drift <email@hidden> wrote:
>
> On Oct 1, 2012, at 6:31 PM, Mike Abdullah <email@hidden> wrote:
>
>> Yes, you don't understand the consequences of your code yet. AppKit is not threadsafe. You absolutely MUST only update UI on the main thread for something like this.
>>
>> Make sure your -parseData routine is threadsafe, and then bounce back over to the main thread for -finishedTask.
>
> Oh I think I see now what I did wrong. Since I update the array *during* the parse, the tableview already gets updated as well since it is bound to the array. So I either need to update the array on the main thread, or wait with updating it until after parseData is done. I'll try what works best.
>
> - 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