Contents

CFBundleCopyResourceURLInDirectory(_:_:_:_:)

Returns the location of a resource contained in the specified bundle directory without requiring the creation of a CFBundle object.

Declaration

func CFBundleCopyResourceURLInDirectory(_ bundleURL: CFURL!, _ resourceName: CFString!, _ resourceType: CFString!, _ subDirName: CFString!) -> CFURL!

Parameters

  • bundleURL:

    The bundle to examine.

  • resourceName:

    The name of the requested resource.

  • resourceType:

    The abstract type of the requested resource. The type is expressed as a filename extension, such as jpg. Pass NULL if you don’t need to search by type.

  • subDirName:

    The name of the subdirectory of the bundle’s resources directory to search. Pass NULL to search the standard CFBundle resource locations.

Return Value

A CFURL object describing the location of the requested resource, or NULL if the resource cannot be found. Ownership follows the The Create Rule.

Discussion

This function provides a means to obtain package information for a bundle without first creating a bundle. However, since CFBundle objects cache search results, it is faster to create a CFBundle object if you need to repeatedly access resources.

Note that searches are case-sensitive, even on file systems (such as HFS+) that are not case sensitive with regards to file names.

See Also

Locating Bundle Resources