Contents

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 matches name.

  • 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