url(forResource:withExtension:subdirectory:in:)
Creates and returns a file URL for the resource with the specified name and extension in the specified bundle.
Declaration
class func url(forResource name: String?, withExtension ext: String?, subdirectory subpath: String?, in bundleURL: URL) -> URL?Parameters
- name:
The name of the resource file.
If you specify
nil, the method returns the first resource file it finds that matches the remaining criteria. - ext:
The filename extension of the file to locate.
If you specify an empty string or
nil, the extension is assumed not to exist and the file URL is the first file encountered that exactly matchesname. - subpath:
The name of the bundle subdirectory to search.
- bundleURL:
The file URL of the bundle to search.
Return Value
The file URL for the resource file or nil if the file could not be located.
See Also
Finding Resource Files
url(forResource:withExtension:subdirectory:)url(forResource:withExtension:)urls(forResourcesWithExtension:subdirectory:)url(forResource:withExtension:subdirectory:localization:)urls(forResourcesWithExtension:subdirectory:localization:)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:)