discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUnarchiver extensions


From: Pierre-Yves Rivaille
Subject: Re: NSUnarchiver extensions
Date: Tue, 26 Feb 2002 13:34:44 +0100

Unless I'm missing something, I think the change is pointless (and therefore
bloat).
It seems to me that if you are substituting one class for another when
decoding, the replacement class
*must* know all about the class it is replacing.

The problem is that the initWithCoder is used to decode GSCustomView object *and* GormCustomView object too. And there is no easy way to know if I'm decoding a GSCustomView or a GormCustomView, so I don't know if I should call [aCoder versionForClassName: @"GSCustomView"] or [aCoder versionForClassName: @"GormCustomView"].
Calling the wrong [aCoder versionForClassName: @"..."] leads to a segfault.

Another way to do thing would be to patch the [NSUnarchiver versionForClassName:] methods so that it returns a specific value when the class does not exist in the archive (maybe NSNotFound, but it may interact with some class's version, although it is unlikely), or maybe raise an exception. (I've implemented the first solution at some point but I dumped it for some reason I forgot ..., but i've never played with exceptions in objc).

(The dirty trick solution would be to turn on and off a class variable for GormCustomView before and after loading a nib file, so that it knows when it is used to decode a GSCustomView or a GormCustomView.)

        Pierre-Yves




reply via email to

[Prev in Thread] Current Thread [Next in Thread]