Re: can't archive NSValue
Re: can't archive NSValue
- Subject: Re: can't archive NSValue
- From: Ondra Cada <email@hidden>
- Date: Tue, 25 Apr 2006 00:50:05 +0200
Ken,
On 24.4.2006, at 23:01, Ken Victor wrote:
the following raises an exception and prints a message on the
console log:
[coder encodeObject: [NSValue valueWithPointer: [self controller]]
forKey: @"controller"];
this is inside my encodeWithCoder: (NSCoder*) coder method. the
message i get on the console is:
cannot encode (void *) value: <0013a6dc >
note that [self controller] returns a valid pointer. i've changed
my code to use NSData instead so as not to be blocked...
according to the docs, NSValue adheres to NSCoding, so i believe my
original code should have worked. did i do something wrong? or is
this a bug? and if a bug, is this a framework bug or a doc bug?
Doc bug, I guess.
At the moment I have no time to test it, but I *assume* (possibly I
am wrong!) the NSValue is trying to be clever, and does not allow you
to archive a pointer since it is generally worthless.
The trick is, any pointer is a transient thing, valid in the current
process only. If you unarchive the data in another process, the
pointer would be invalid, or it would point to something else, or so.
If you do know it is all right (e.g., you are using the archiver to
duplicate objects subnet or something similar), trick it over by
storing the pointer as an integer.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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