---
title: "init(name:subdirectory:locale:bundle:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/urlresource/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.

## Declaration

```swift
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 doc://com.apple.foundation/documentation/Foundation/Locale/current.
- `bundle`: The bundle containing the resource. This defaults to doc://com.apple.foundation/documentation/Foundation/Bundle/main.
