Monday, April 29, 2013

NSBundle URLsForResourcesWithExtension example ios


URLsForResourcesWithExtension :subdirectory:inBundleWithURL:

Returns an array containing the file URLs for all bundle resources having the specified filename extension, residing in the specified resource subdirectory, within the specified bundle.
+ (NSArray *)URLsForResourcesWithExtension:(NSString *)ext subdirectory:(NSString *)subpath inBundleWithURL:(NSURL *)bundleURL
Parameters of [NSBundle URLsForResourcesWithExtension]
ext
The file extension of the files to retrieve.
subpath
The name of the bundle subdirectory to search.
bundleURL
The file URL of the bundle to search.
Return Value of [NSBundle URLsForResourcesWithExtension]
The file URL for the resource file or nil if the file could not be located.
Example of [NSBundle URLsForResourcesWithExtension]
NSArray * array = [NSBundle URLsForResourcesWithExtension:@"png" subdirectory:nil inBundleWithURL:[[NSBundle mainBundle] bundleURL]];
    [array indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
        return [obj isKindOfClass:NSURL.class] && [[((NSURL *) obj) resourceSpecifier] hasPrefix:@"image"];
    }];