I am reading tutorial book now. When I see an example, I get some confused. The following codes show a way for lazy loading. Does this motivations array be released after instance deallocated ? or will it occupy this memory block until application terminates.
+ (NSArray *)motivations
{
static NSArray *motivations = nil;
if (!motivations)
{
motivations = [[NSArray alloc] initWithObjects:@"Greed",@"Revenge",@"Bloodlust",@"Nihilism",@"Insanity",nil];
}
return motivations;
}
Edit 1 Thank Georg for a bug.