Hello all,
I have a file with a fixed name "dog" in the resource dir. This file could be "dog.jpg", "dog.png", "dog.gif", "dog.txt", "dog.wav". I would like to find file based on the extension: If "dog.jpg" does not exist, then it should look for the next "dog.png" and so on. I mean something like NSArray *fileTypes below with only 3 defined filetypes to looking for. Any help would be much appreciated, Thank you!
I have a file with a fixed name "dog" in the resource dir. This file could be "dog.jpg", "dog.png", "dog.gif", "dog.txt", "dog.wav". I would like to find file based on the extension: If "dog.jpg" does not exist, then it should look for the next "dog.png" and so on. I mean something like NSArray *fileTypes below with only 3 defined filetypes to looking for. Any help would be much appreciated, Thank you!
PHP:
NSBundle *bundle;
NSString *Path;
bundle = [NSBundle mainBundle];
//NSArray *fileTypes = [NSArray arrayWithObjects:@"jpg", @"gif", @"png", nil];
Path = [bundle pathForResource:@"dog" ofType:fileTypes];
if (!Path) {
NSLog(@"ERROR: Cannot find the dog file.\n");
} else {
NSLog(@"FOUND: Filename is: %@\n", Path);
}