I have code similar to this in Objective-C:
SubclassOfNSObject *GlobalVariableThatShouldNeverChange;
@implementation MyClass
+(void) initialize
{
[super initialize];
GlobalVariableThatShouldNeverChange = [[SubclassOfNSObject alloc] init];
// Change more stuff with GlobalVariableThatShouldNeverChange
}
@end
I have this referenced throughout code, and the pointer to this should never change because I am using it everywhere through my code.
The problem is, that when I run my tests using GHUnit
, I have odd problems with the GlobalVariableThatShouldNeverChange
's pointer being changed (i.e. It is being reinitialized. I had a problem with the variable being released via the autorelease pool and that is fixed, and I have a workaround for this problem, but I would like to know why?
Thank you!