• 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: NSKeyedArchiver exception
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSKeyedArchiver exception


  • Subject: Re: NSKeyedArchiver exception
  • From: Ken Victor <email@hidden>
  • Date: Mon, 19 Sep 2005 18:53:51 -0700

will,
thanx for the reply. i probably should have mentioned in my original message that the following works fine:
NSData* pd = [NSKeyedArchiver archivedDataWithRootObject: [myDoc printInfo]];


its only when i first convert the NSPrintInfo to a dictionary and then back to a NSPrintInfo that the exception is thrown. thus, i don't think your explanation is correct. and all the documentation i've read states that in order to save print info on a per document basis to first flatten it via a NSKeyedArchiver. and thats what i'm trying to do. the reason that i have to use the dictionary is that i'm programmatically changing some "attributes" of the print info. that was failing so i narrowed it down and discovered the simple case that fails.

ken



At 6:20 PM -0700 9/19/05, email@hidden wrote:
Hi, Ken,
You're not doing anything wrong. If you look at the declaration of NSPrintInfo, you'll see:


 @interface NSPrintInfo : NSObject<NSCopying, NSCoding> {
 ¬Ý¬Ý¬Ý @private
 ¬Ý¬Ý¬Ý NSMutableDictionary *_attributes;
 ¬Ý¬Ý¬Ý void *_moreVars;
 }

It's a pretty safe bet to guess that _moreVars is an instance of a private structure. The fact that NSKeyedArchiver won't encode structs also means that it won't encode NSPrintInfo instances either. This is not particularly surprising, as the Next runtime's lack of support for determining the exact layout of a struct makes the task amazingly tedious. Believe me, I've done it. The GNU runtime, on the other hand, is great for this. :) In your case, though, it's difficult to suggest an alternative other than avoiding trying to archive instances of NSPrintInfo.

 Sorry I can't be more helpful,
 Will

----- Original Message ----

i've narrowed a problem i'm getting to the following 3 lines of code:

¬Ý¬Ý¬Ý¬ÝNSMutableDictionary* piDict = [[myDoc printInfo] dictionary];
¬Ý¬Ý¬Ý¬ÝNSPrintInfo* newPI = [[NSPrintInfo alloc] initWithDictionary: piDict];
¬Ý¬Ý¬Ý¬ÝNSData* pd = [NSKeyedArchiver archivedDataWithRootObject: newPI];

the third line throws the following exception:

¬Ý¬Ý¬Ý¬Ý*** -[NSKeyedArchiver encodeValueOfObjCType:at:]: this
archiver cannot encode structs

i've searched the archives and didn't find anything that would explain this.

what am i doing wrong?
_______________________________________________
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


  • Prev by Date: Entourage nightmare
  • Next by Date: Finding Jars - Class not found
  • Previous by thread: Re: NSKeyedArchiver exception
  • Next by thread: Trouble with NSKeyValueChangeInsertion
  • Index(es):
    • Date
    • Thread