views:

334

answers:

2

Sorry, dumb question number 2 today. Is it possible to determine if a file is contained within the App Bundle? I can access files no problem, i.e.,

NSString *pathAndFileName = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"];

But can't figure out how to check if the file exists there in the first place.

Regards

Dave

+5  A: 
[[NSFileManager defaultManager] fileExistsAtPath:pathAndFileName];
Rob Napier
Doh! thanks Rob, have been using that for files in the documents directory! It's getting late. Thanks again.
Magic Bullet Dave
A: 
NSFileManager *fileManager = [NSFileManager defaultManager];
    NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"filename"];
    if(![fileManager fileExistsAtPath:path])
    {
        // do something
    }
Iggy