Hi,

Since saving a document can be a lengthy process in one of my apps, I am 
switching it to a concurrent thread. My idea is to do the following:

- (void)saveToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
forSaveOperation:(NSSaveOperationType)saveOperation delegate:(id)delegate 
didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo
{
        NSBlockOperation *operation = [NSBlockOperation 
blockOperationWithBlock: ^{
                [super saveToURL:absoluteURL ofType:typeName 
forSaveOperation:saveOperation delegate:delegate 
didSaveSelector:didSaveSelector contextInfo:contextInfo];
        }];
        [((MyAppDelegate *)[NSApp delegate]).operationQueue 
addOperation:operation];    
}

This allows the Save panel to be presented, if needed, on the main thread, and 
performs the actual saving in the background. Initial testing suggests that 
this is a workable solution and even allows multiple documents to be saved 
concurrently within the app. The recent menu appears to be correctly updated, 
as well as document dirty status, etc.

My question is: can anyone see any possible gotchas with this technique? Any 
subtle ways in which things might not work as dependably as they appear?

Cheers,
António

----------------------------------------------------
It isn't so important to do great things,
as to do what you do with great love.
----------------------------------------------------



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to