Re: NSUnarchiver unarchiveObjectWithData problem
Re: NSUnarchiver unarchiveObjectWithData problem
- Subject: Re: NSUnarchiver unarchiveObjectWithData problem
- From: Gus Mueller <email@hidden>
- Date: Mon, 16 Jun 2003 20:14:37 -0700
I'm still trying to figure out this problem I'm having with
NSUnarchiver- I've simplified the code quite a bit to what you see
below. All I'm doing is loading in a RTF with the Zapfino font + funky
letter A, archive it, and unarchive it. Then bang! I get the
exception. Seems kind of strange to me.
Just a fair warning first- the code below loads a RTF over the network (
http://gusmueller.com/zap.rtf ), in case anybody wants to try it over a
modem.
I compile it like so:
cc -framework Cocoa nph.m
run it as such:
./a.out
and it produces the output:
2003-06-16 22:04:46.392 a.out[1328] s: this char right here will barf:
\\ufffd
2003-06-16 22:04:46.395 a.out[1328] *** Uncaught exception:
<NSInvalidArgumentException> *** -[NSPlaceholderDictionary
initWithObjects:forKeys:count:]: attempt to insert nil value
Trace/BPT trap
thanks in advance for any help or advice,
-gus
#import <Cocoa/Cocoa.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *ss = [NSString stringWithContentsOfURL:[NSURL
URLWithString:@"
http://gusmueller.com/zap.rtf"]];
NSMutableAttributedString *s = [[NSMutableAttributedString alloc]
initWithRTF:[ss
dataUsingEncoding:NSUTF8StringEncoding]
documentAttributes:NULL];
// it's a good string at this point:
NSLog(@"s: %@", [s string]);
// archive it.
NSData *data = [NSArchiver archivedDataWithRootObject:s];
// Then try and unarchive it, but this throws the exception-
s = [NSUnarchiver unarchiveObjectWith
Data:data];
// we never get to see what it is...
// *** -[NSPlaceholderDictionary initWithObjects:forKeys:count:]:
attempt to insert nil value
NSLog(@"%@", [s string]);
[pool release];
return 0;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.