views:

101

answers:

1

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!

+3  A: 
NSMutableDictionary *readDict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"Stuff.plist"];

This line tries to read file from the bundle directory. Read file from full path:

NSMutableDictionary *readDict = [[NSMutableDictionary alloc] initWithContentsOfFile:docsDirectoryWithPlist];
kovpas