URLForResource :withExtension:subdirectory:inBundleWithURL:
Creates and returns a file URL for the resource with the specified name and extension in the specified bundle.
+ (NSURL *)URLForResource:(NSString *)name withExtension:(NSString *)extsubdirectory:(NSString *)subpath inBundleWithURL:(NSURL *)bundleURL
Parameters
- name
- The name of the resource file.
- extension
- If extension is an empty string or
nil
, the extension is assumed not to exist and the file URL is the first file encountered that exactly matches name.[NSBundle URLForResource] - subpath
- The name of the bundle subdirectory to search.
- bundleURL
- The file URL of the bundle to search.
Return Value of [NSBundle URLForResource]
The file URL for the resource file or
nil
if the file could not be located.
Example of [NSBundle URLForResource]
- (void)testBundleLocation
{
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [bundle URLForResource:@"myDataModel" withExtension:@"momd"];
...
}