writeToFile: causes app to crash when save on quit.
writeToFile: causes app to crash when save on quit.
- Subject: writeToFile: causes app to crash when save on quit.
- From: Ron Ballesteros <email@hidden>
- Date: Tue, 30 Dec 2003 16:15:26 -0800
Hi ,
So I have a small app that saves a tree data structure that is composed
of NSMutableDictionary, NSMutableArray and NSStrings. Before the
application completely quits I save the tree structure to a file using
writeToFile: of NSDictionary.
However when the application is about to quit, the application exits
due to signal 11 (SIGSEGV) and it occurs when attempting writeToFile.
I thought that maybe I was releasing some of the objects contained in
the structure to early so I commented out the code that adds content to
the structure and just left initialized to it's empty form and it still
crashed.
I know I'm missing something very obvious and stupid but forgive me as
I can't seem to trace it down.
Thanks .
~r
Below is the snippet of my code: where I create the initial tree
structure and when I save it:
- (id)init {
if (self = [super init]) {
//Initliaze and create the rootNode
NSString *rootName = @"schedules";
NSMutableArray *sevenDaySchedules = [[NSMutableArray alloc] init];
//rootNode is an instance variable
rootNode = [NSMutableDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:rootName,sevenDaySchedules, nil] forKeys:
[NSArray arrayWithObjects:@"rootName", @"sevenDaySchedules", nil]];
}
return self;
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(id)sender
{
NSString *scheduleStorePath = [NSHomeDirectory()
stringByAppendingPathComponent:@"Documents/schedules.hrs"];
[rootNode writeToFile:scheduleStorePath atomically:YES];
return NSTerminateNow;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.