<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLResource/init(name:subdirectory:locale:bundle:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11URLResourceV4name12subdirectory6locale6bundleACSS_SSSgAA6LocaleVSo8NSBundleCtcfc"
  },
  "title" : "init(name:subdirectory:locale:bundle:)"
}
-->

# init(name:subdirectory:locale:bundle:)

Creates a URL resource from the given bundle, name, and subdirectory, optionally specifying a locale.

```
init(name: String, subdirectory: String? = nil, locale: Locale = .current, bundle: Bundle = .main)
```

## Parameters

`name`

The name of the resource in the bundle. This should include both the resource name and its extension, to avoid confusion.

`subdirectory`

The subdirectory, if any, of the resource.

`locale`

The locale of the resource, as provided by the process that creates the resource. This defaults to [`current`](/documentation/Foundation/Locale/current).

`bundle`

The bundle containing the resource. This defaults to [`main`](/documentation/Foundation/Bundle/main).

---

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)