urls(forResourcesWithExtension:subdirectory:)
Returns an array of file URLs for all resources identified by the specified file extension and located in the specified bundle subdirectory.
Declaration
func urls(forResourcesWithExtension ext: String?, subdirectory subpath: String?) -> [URL]?Parameters
- ext:
The filename extension of the files to locate.
If you specify an empty string or
nil, the extension is assumed not to exist and all of the files insubpathare returned. - subpath:
The name of the bundle subdirectory.
Return Value
An array of file URLs for the resource files or nil if no files could be located at subpath with extension. Returns an empty array if no matching resource files are found.
Discussion
If subpath is nil, this method searches the top-level non-localized resource directory and the top-level of any language-specific directories. (In macOS, the top-level non-localized resource directory is typically called Resources but in iOS, it is the main bundle directory.)
For example, suppose you have a Mac app with a modern bundle and you specify @"Documentation" for the subpath parameter. This method would first look in the Contents/Resources/Documentation directory of the bundle, followed by the Documentation subdirectories of each language-specific .lproj directory. (The search order for the language-specific directories corresponds to the user’s preferences.) This method does not recurse through any other subdirectories at any of these locations. For more details see The Bundle Search Pattern in Bundle Programming Guide.
See Also
Finding Resource Files
url(forResource:withExtension:subdirectory:)url(forResource:withExtension:)url(forResource:withExtension:subdirectory:localization:)urls(forResourcesWithExtension:subdirectory:localization:)url(forResource:withExtension:subdirectory:in:)urls(forResourcesWithExtension:subdirectory:in:)path(forResource:ofType:)path(forResource:ofType:inDirectory:)path(forResource:ofType:inDirectory:forLocalization:)paths(forResourcesOfType:inDirectory:)paths(forResourcesOfType:inDirectory:forLocalization:)path(forResource:ofType:inDirectory:)paths(forResourcesOfType:inDirectory:)