gnustep-dev
[Top][All Lists]
Advanced

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

Re: Archiving GUI elements


From: Richard Frith-Macdonald
Subject: Re: Archiving GUI elements
Date: Mon, 1 Oct 2001 09:49:17 +0100

On Monday, October 1, 2001, at 02:48 AM, Adam Fedor wrote:

Just a note for future reference. I'm designing Gorm inspectors using Gorm itself, which means I'm using archiving to store the inspectors. In the future, if you change the coding procedure for a GUI element, please leave a path for reading in old archived files.

It's probably possible to do this even temporarily (say with ifdefs), since GUI is still in beta and Gorm is perhaps the only app that is doing this (although GNUMail also archives images). Really, there are clean ways to do this also (perhaps the best is by increasing the class version).

For those of you who don't know ... the clean way to do this is using the -versionForClassName: method (see NSCoder documentation) and the +setVersion: method (see NSObject documentation).

So your code would look like this -

static const int        currentVersion = xxx;           // Current version

- (void) initialize
{
  if (self == [MyClass class])
    {
      [self setVersion: currentVersion];
    }
}

- (id) initWithCoder: (NSCoder*)aCoder
{
int version = [aCoder versionForClassName: NSStringFromClass([self class])];

  if (version < currentVersion)
    {
       ....
    }
  ....
  return self;
}


Typically, this sort of thing should be done to handle changes in archiving formats between
and within releases of the libraries.

When we make a release of the base library, we update the system version ... and this
makes it possible for us to write much more efficient code -

- (id) initWithCoder: (NSCoder*)aCoder
{
  int   systemVersion = [aCoder systemVersion];
  int   version;

  if (systemVersion <= lastVersionWithFormatChanges)
    {
version = [aCoder versionForClassName: NSStringFromClass([self class])];
    }
  else
    {
      version = currentVersion;
    }

 if (version < currentVersion)
    {
       ....
    }
  ....
  return self;
}






reply via email to

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