Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you determine if a file exists within the app bundle?

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

like image 662
Magic Bullet Dave Avatar asked Jan 07 '10 22:01

Magic Bullet Dave


2 Answers

[[NSFileManager defaultManager] fileExistsAtPath:pathAndFileName]; 
like image 82
Rob Napier Avatar answered Sep 18 '22 08:09

Rob Napier


This code worked for me...

NSString *pathAndFileName = [[NSBundle mainBundle] pathForResource:fileName ofType:nil]; if ([[NSFileManager defaultManager] fileExistsAtPath:pathAndFileName]) {     NSLog(@"File exists in BUNDLE"); } else {     NSLog(@"File not found"); } 

Hopefully, it will help somebody...

like image 27
Arkady Avatar answered Sep 21 '22 08:09

Arkady