NSBundle pathForResource returns nil with subdirs NSBundle pathForResource returns nil with subdirs xcode xcode

NSBundle pathForResource returns nil with subdirs


If you need to access a file in a directory, you should be using -[NSBundle pathForResource:ofType:inDirectory:] instead. So your code should instead look like

NSString *images_misc_file = [[NSBundle mainBundle] pathForResource:@"mainmenu_background" ofType:@"png" inDirectory:@"images/misc"];


Even though this has been answered already, I would like to add that -[NSBundle pathForResource:ofType:inDirectory:] has different case-sensitivity depending whether it is iPhone simulator or iPad simulator or the device. For example, iPhone Simulator 4.0 it seems to be case insensitive, while on iPad Simulator 3.2 and the device - case sensitive. Thus files that are found on iPhone 4.0 simulator might not be found on IPad Simulator 3.2 or the device if the cases don't match.