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: Chris Ridd <email@hidden>
- Date: Fri, 04 Aug 2006 08:43:29 +0100
- Thread-topic: Core Data: Progress bar using Sheet, modifying context in thread
On 4/8/06 5:05, Bill Coleman <email@hidden> wrote:
>
> Hi. I'm relatively new to Cocoa. Although I've dabbled with it for
> five years, this summer is the first time I've gotten serious with
> it. I've found it to be a powerful and relatively complete framework,
> and that often if something is hard to do, I must be doing it wrong.
> Writing the application is easy. Figuring out how to do it is hard.
>
> I have a relatively simple application that keeps a single list of
> rows using Core Data, and displays the list in an NSTableView. I've
> written an import / export operation to move data from and to this
> list via a different text format.
>
> Question 1: I'd like the import or export process to be document-
> modal, with the progress of the operation displayed in a sheet. This
> is a little tricky, since once you call beginSheet:
> modalForWindow: ..., you can't do any more processing. So, to perform
> the actual operation, I first start an NSThread. Getting it to quit
> properly was tricky, as you have to use performSelectorOnMainThread:
> to get the endSheet: call to work.
>
> My question is -- is this the right way to do this? Is there a better
> way? It seems to be fraught with problems.
I think your thread should be creating a temporary copy of your data as it
reads it in. Then in the endSheet: you should replace the entire old model
with the new data (there are methods to do bulk changes like this, IIRC) or
merge the two, or punt if there was a problem, etc etc.
Cheers,
Chris
_______________________________________________
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