I have the following code that fails when i run it. my .h file:
@interface OutlineManager : NSObject
{
NSMutableArray* mOutlines;
}
@property(nonatomic,strong)NSMutableArray* Outlines;
+(void)initialize;
@end
static OutlineManager* outlnManager;
in the .m file:
#import "OutlineManager.h"
@implementation OutlineManager
@synthesize Outlines = mOutlines;
+(void)initialize
{
outlnManager = [[[OutlineManager superclass]alloc]init];
if(outlnManager)
{
outlnManager.Outlines = [[NSMutableArray alloc]init]; //it crashes here
}
NSLog(@"OUTLINEMANAGER INITIALIZED");
}
@end
when i run (void)initialize the application crashes in the if section where i put the comment, but i don”t know why. Can’t I init an array of a static object like this?
I guess it’s something very basic, but i’m pretty new at Obj C /iOS , so please don’t hold this against me.
Thank you very much for your help!
Sincerely, Zoli
You wrote:
That superclass means you calling alloc on NSObject and not on OutlineManager.
Just replace this line with this:
Oh and you should declare your static variables in the .m file.