• 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
NSKeyedUnarchiver - unarchiving on a background thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSKeyedUnarchiver - unarchiving on a background thread
      • From: email@hidden
  • Prev by Date: Re: Welcome to the "Cocoa-dev" mailing list
  • Next by Date: NSUserDefaults example?
  • Previous by thread: enable binding in tableView - was Re: Welcome to the "Cocoa-dev" mailing list
  • Next by thread: Re: NSKeyedUnarchiver - unarchiving on a background thread
  • Index(es):
    • Date
    • Thread