• 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
Re: Bug when encoding subclasses of NSData?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug when encoding subclasses of NSData?


  • Subject: Re: Bug when encoding subclasses of NSData?
  • From: James Spencer <email@hidden>
  • Date: Fri, 19 Dec 2003 19:10:20 -0600

I'm assuming your problem is arising from the fact that NSData is a class cluster and must be subclassed following the rules for subclassing clusters. See http://developer.apple.com/documentation/Cocoa/Conceptual/Foundation/ Concepts/ClassClusters.html for more information.

Spence

On Dec 19, 2003, at 2:46 PM, Jonathan Wight wrote:

I haven't been able to solve this problem so I thought I'd bump the
original email and see if anyone on the list has a solution? (Come on
it _is_ the season of giving after all! ;-)

Jon.

On Dec 16, 2003, at 15:05, 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?

[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.


James P. Spencer
Rochester, MN

email@hidden

"Badges?? We don't need no stinkin badges!"
_______________________________________________
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.

  • Follow-Ups:
    • Re: Bug when encoding subclasses of NSData?
      • From: Jonathan Wight <email@hidden>
References: 
 >Bug when encoding subclasses of NSData? (From: Jonathan Wight <email@hidden>)
 >Re: Bug when encoding subclasses of NSData? (From: Jonathan Wight <email@hidden>)

  • Prev by Date: Parsing XML and DTD's (XML Newbie)
  • Next by Date: Re: Bug when encoding subclasses of NSData?
  • Previous by thread: Re: Bug when encoding subclasses of NSData?
  • Next by thread: Re: Bug when encoding subclasses of NSData?
  • Index(es):
    • Date
    • Thread