Ok, so here's an interesting problem with a Cocoa application I'm building.
The basis of this application is an NSMutableArray. When I close the program, it uses this code to save the array;
Then, when the program starts, it uses the following code to load the array(after initializing it of course);
Now, when I run the program once, it works fine. When I close it, it creates the data file. However, when I run the program a second time to load the saved information, I get a EXC_BAD_ACCESS error sometime after it loads the array. Could this have something to do with access permissions for the file in question?
PS. I looked up this error message, and everything I find on google points to memory management issues dealing with retaining and releasing objects. My understanding is that since my project is set to use Garbage Collector, I don't have to worry about retain, release and autorelease commands, is that correct?
The basis of this application is an NSMutableArray. When I close the program, it uses this code to save the array;
Code:
NSString *path = [self pathForDataFile];
NSMutableDictionary *rootObject;
rootObject = [NSMutableDictionary dictionary];
[rootObject setValue: partsList forKey:@"partsList"];
[NSKeyedArchiver archiveRootObject: rootObject toFile: path];
Then, when the program starts, it uses the following code to load the array(after initializing it of course);
Code:
NSString *path = [self pathForDataFile];
NSDictionary *rootObject;
rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
setPartsList: [rootObject valueForKey:@"partsList"];
Now, when I run the program once, it works fine. When I close it, it creates the data file. However, when I run the program a second time to load the saved information, I get a EXC_BAD_ACCESS error sometime after it loads the array. Could this have something to do with access permissions for the file in question?
PS. I looked up this error message, and everything I find on google points to memory management issues dealing with retaining and releasing objects. My understanding is that since my project is set to use Garbage Collector, I don't have to worry about retain, release and autorelease commands, is that correct?