iPhone app throwing EXC_BAD_ACCESS with dictionary from contents of file

Posted by Mark Szymanski on Stack Overflow See other posts from Stack Overflow or by Mark Szymanski
Published on 2010-04-26T23:45:27Z Indexed on 2010/04/27 7:13 UTC
Read the original article Hit count: 296

I have the code

 NSArray *paths = [[NSArray alloc]   
initWithArray:NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)]; 

NSString *docsDirectory = [[NSString alloc] initWithString:[paths objectAtIndex:0]];

NSLog(@"This app's documents directory: %@",docsDirectory);

NSString *docsDirectoryWithPlist = [[NSString alloc] initWithFormat:@"%@/Stuff.plist", docsDirectory];



BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:docsDirectoryWithPlist isDirectory:NO];

if (fileExists) 
{
    chdir([docsDirectory UTF8String]);
    NSMutableDictionary *readDict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"Stuff.plist"];

in an application's applicationDidFinishLaunching method and whenever it gets to the last line it crashes, throwing EXC_BAD_ACCESS along the way.

Thanks in advance!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about exc-bad-access