NSKeyedUnarchiver - unarchiving on a background thread
NSKeyedUnarchiver - unarchiving on a background thread
- Subject: NSKeyedUnarchiver - unarchiving on a background thread
- From: nick briggs <email@hidden>
- Date: Thu, 10 Feb 2005 21:03:13 +0000
All
My documents can become complex and can take a while to open. As such I am looking for a way to
1) manage the unarchiving in a background thread
2) free up the UI, especially the File Menu.
3) provide feedback, e.g, a progress indicator, as the document loads
As a strating point I tried the code below, which detatches a new thread and crashes with...
*** -[NSCFString count]: selector not recognized
*** -[NSCFString count]: selector not recognized
Is NSKeyedUnarchiver not threadsafe?
Has anyone implemented a system which meets my goals?
Thanks
Nick
- (BOOL)loadDataRepresentation:(NSData*)data ofType:(NSString*)type
{
/**
//THIS WORKS....
NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
[_stuff release];
_stuff = [[unarchiver decodeObjectForKey:@"stuff"] retain];
[unarchiver finishDecoding];
[unarchiver release];
**/
[NSThread detachNewThreadSelector:@selector(unarchiveThread:)
toTarget:self
withObject:data];
return YES;
}
- (void)unarchiveThread:(NSData*)data
{
//THIS BREAKS
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
[_stuff release];
_stuff = [[unarchiver decodeObjectForKey:@"stuff"] retain];
[unarchiver finishDecoding];
[unarchiver release];
[pool release];
}
_______________________________________________
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