<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Bundle/urls(forResourcesWithExtension:subdirectory:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBundle(im)URLsForResourcesWithExtension:subdirectory:"
  },
  "title" : "urls(forResourcesWithExtension:subdirectory:)"
}
-->

# 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.

```
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 in     `subpath`     are 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](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/AccessingaBundlesContents/AccessingaBundlesContents.html#//apple_ref/doc/uid/10000123i-CH104-SW7) in [Bundle Programming Guide](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/Introduction/Introduction.html#//apple_ref/doc/uid/10000123i).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)