A global variable has to be initialized to a constant value, like 4
or 0.0
or @"constant string"
or nil
. A object constructor, such as init
, does not return a constant value.
If you want to have a global variable, you should initialize it to nil
and then return it using a class method:
NSImage *segment = nil;
+ (NSImage *)imageSegment
{
if (segment == nil) segment = [[NSImage alloc] initWithContentsOfFile:@"/user/asd.jpg"];
return segment;
}