discuss-gnustep
[Top][All Lists]
Advanced

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

+initialize and static (class) variables


From: Aurelien
Subject: +initialize and static (class) variables
Date: Tue, 4 Sep 2001 17:55:55 +0200

Hi again,

(My previous problem with exceptions actually boiled down to this one)

I have an implementation like so:

static NSArray *advRequiredConstructors;
static AdvertisementFactory *advFactory;

@implementation AdvertisementFactory

+ initialize
{
  NSLog ( @"Calling initialize" );
  advFactory = [[AdvertisementFactory alloc] init];
  advRequiredConstructors = [[NSArray alloc] initWithObjects: nil];
}
....

As you can see, this is a singleton class. It turns out, strangely, that initializing advFactory works, but the program hangs when it's advRequiredConstructors' turn (i.e. commenting out the last line gets the job done)

I have to mention that I *did* something wrong from the start, but until now there was no problem with that. I still don't have my mind set about the AutoreleasePool bits, so I didn't create one in the beginning. Could that be the problem ? Also, it would be nice from one of you to send me the snippet that sets up the AutoreleasePool !

Cheers,

Aurélien



reply via email to

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