>>> I don't think so, Jens. "They" is Apple. Apple has the source code for
>>> -initWithCoder: and -encodeWithCoder:.
>>
>> No they don’t — not for the implementations of those methods in our own
>> classes…
>
> Thank you, Jens. I see the problem.
>
> Here's a fairly radical solution:
...
> @implementation NSObject (LookMaNoEncodingExceptions)
>
> - (void)encodeWithCoder:(NSCoder*)coder {
> NSString* archivoid = [NSString stringWithFormat:
> @"Sorry, %@ is not encodable.\n"
> @"Here's a description of it: %@",
> [self className],
> [self description]] ;
> [coder encodeObject:archivoid
> forKey:@"Archivoid"];
> }
This is even worse than the original problem. Rather than getting an exception
at the time of encoding, now you're silently converting unencodable objects to
strings. When you unarchive one of those strings, code expecting an instance of
UnencodableFoo will instead have an NSString, the use of which will likely
throw exceptions, eg: when code calls -[UnencodableFoo fooThing]
~Martin
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]