• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data: Progress bar using Sheet, modifying context in thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Core Data: Progress bar using Sheet, modifying context in thread (From: Bill Coleman <email@hidden>)
 >Re: Core Data: Progress bar using Sheet, modifying context in thread (From: Andreas Mayer <email@hidden>)
 >Re: Core Data: Progress bar using Sheet, modifying context in thread (From: Bill Coleman <email@hidden>)

  • Prev by Date: Re: Core Data: Progress bar using Sheet, modifying context in thread
  • Next by Date: Re: refreshObject:mergeChanges: vs. stale transient properties
  • Previous by thread: Re: Core Data: Progress bar using Sheet, modifying context in thread
  • Next by thread: Re: Core Data: Progress bar using Sheet, modifying context in thread
  • Index(es):
    • Date
    • Thread