Re: Core Data: Progress bar using Sheet, modifying context in thread
Re: Core Data: Progress bar using Sheet, modifying context in thread
- Subject: Re: Core Data: Progress bar using Sheet, modifying context in thread
- From: PGM <email@hidden>
- Date: Fri, 4 Aug 2006 20:54:50 -0400
As others have already said, you should not access your progress bar
from the new thread. But you also have "progressInfo" whose
stringValue you set, which is most likely a NSTextField and thus a
user interface item, so you should also access that from the main
thread. Here are some tips how I would do it.
[progressBar setMinValue: 0];
[progressBar setMaxValue: [importString length] ];
[progressBar setDoubleValue: 0 ];
You should do these things before you spawn your new thread. As you
don't have importString yet, set the maxValue to 100.0. The problem
with using performSelectorOnMainThread is that it takes an object as
an argument, and NSPogressIndicator takes a double as an argument. So
you have to write your own method for this (or a category!), which
can be as simple as:
-(void)setNumberValue:(NSNumber *)value
{
[progressBar setDoubleValue:[value doubleValue]]; //or send this to
self if it's a category
}
to work around the fact that you do not know the length of the
importString, you have to send the progressBar a value of:
[NSNumber numberWithDouble 100.0*pos/[importString length]]
Hope this helps, Patrick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden