Re: Bug when encoding subclasses of NSData?
Re: Bug when encoding subclasses of NSData?
- Subject: Re: Bug when encoding subclasses of NSData?
- From: Jonathan Wight <email@hidden>
- Date: Sat, 20 Dec 2003 20:11:06 -0600
That seemed to do the trick! Many thanks!
Jon.
On Dec 20, 2003, at 15:17, Christopher Kane wrote:
>
Did you override -classForCoder in your subclass? If not, try that
>
({return [self class];}).
>
>
>
Chris Kane
>
Cocoa Frameworks, Apple
>
>
>
On Dec 16, 2003, at 1:05 PM, Jonathan Wight wrote:
>
>
> I have a subclass of NSData that I am providing my own NSCoding
>
> methods
>
> for. When an object of this class is archived I want to archive extra
>
> information alongside the bytes of the object.
>
>
>
> Unfortunately when I try to archive my object only the bytes are
>
> archived and none of my extra information is getting archived. It
>
> turns
>
> out that my subclass's -encodeWithCoder method isn't getting called at
>
> all. I can only assume that NSArchiver recognises my object as an
>
> NSData-like object and thinks it knows how to archive it without
>
> bothering to go through encodeWithCoder.
>
>
>
> Here's the backtrace of the point in the the code where I _think_ the
>
> object is about to be archived...
>
>
>
> #0 -[CMyData bytes] (self=0x5285a0, _cmd=0x9086b8c0) at
>
> /Volumes/Home/schwa/Desktop/DataTest/CMyData.m:48
>
> #1 0x90a2a484 in -[NSData hash] ()
>
> #2 0x90197154 in __CFSetFindBuckets2 ()
>
> #3 0x9019abd4 in CFSetAddValue ()
>
> #4 0x901a30ac in _flattenPlist ()
>
> #5 0x901a323c in _flattenPlist ()
>
> #6 0x901a3198 in _flattenPlist ()
>
> #7 0x901a05e4 in __CFBinaryPlistWriteToStream ()
>
> #8 0x90aae658 in -[NSKeyedArchiver finishEncoding] ()
>
> #9 0x90aac73c in +[NSKeyedArchiver archiveRootObject:toFile:] ()
>
> #10 0x004ddc88 in main (argc=1, argv=0xbffffb80) at
>
> /Volumes/Home/schwa/Desktop/EncryptedObjectTest/main.m:36
>
>
>
> Because NSData supports the NSCoder protocol I would expect the
>
> archiving to go through -encodeWithCoder, but as I've found out it
>
> doesn't seem to. This seems like a definite bug to me... Is this a
>
> known bug and are there any work arounds?
>
>
>
> Cheers.
>
>
>
> Jon.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.