Reputation: 103
I have two text files (.txt) that are in the Documents directory of the Bundle for my project. The files load and work fine when I run the project on the iPhone Simulator in xCode, however the when I run the same project in xCode using my iPhone nothing gets loaded. I have checked and the files don't even exist in the file directory when the iPhone is selected to run the project. Here is the code. Again this works fine and the file exists running under iPhone simulator in xCode, but the file does NOT exist when I run it using my iPhone as the device.
NSArray *arrayPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [arrayPaths objectAtIndex:0];
NSString *path = [docDir stringByAppendingPathComponent:CURRENTPUZZLENUMBERFILE];
NSLog(@"Path = %@", path); // for debugging
bool fileExists = [[NSFileManager defaultManager] fileExistsAtPath:path];
NSLog(@"File exists: %d", fileExists); // for debugging
Upvotes: 0
Views: 195
Reputation: 9414
Grab the file this way then you can copy it to your doc dir if you wish
NSString *filePath = [[NSBundle mainBundle] pathForResource:CURRENTPUZZLENUMBERFILE ofType:@"txt"];
Upvotes: 1