Can anyone tell me what the scope of the static variable in the class below is?
@implementation SharedManager
static id myInstance = nil;
+(id)sharedInstance {
if(myInstance == nil) {
myInstance = [[self alloc] init];
}
return myInstance;
}
In a test I created an instance from the class and then released it, but noticed that on creating a second instance that the static was not nil (i.e. pointing to the previously released object) For the test I fixed this by overriding -(void)dealloc for the class.
-(void)dealloc {
NSLog(@”_deal: %@”, [self class]);
[super release]
myInstance = nil
}
gary