---
title: "init(url:options:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/filewrapper/init(url:options:)-70161"
---

# init(url:options:)

Initializes a file wrapper instance whose kind is determined by the type of file-system node located by the URL.

## Declaration

```swift
init(url: URL, options: FileWrapper.ReadingOptions = []) throws
```

## Parameters

- `url`: URL of the file-system node the file wrapper is to represent.
- `options`: Option flags for reading the node located at url. See doc://com.apple.foundation/documentation/Foundation/FileWrapper/ReadingOptions for possible values.

## Return Value

Return Value File wrapper for the file-system node at url. May be a directory, file, or symbolic link, depending on what is located at the URL. Returns false (0) if reading is not successful.

## Discussion

Discussion If url is a directory, this method recursively creates file wrappers for each node within that directory. Use the fileWrappers property to get the file wrappers of the nodes contained by the directory. note: In Swift, this API is imported as an initializer and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Related Documentation

- [fileWrappers](foundation/filewrapper/filewrappers.md)
- [preferredFilename](foundation/filewrapper/preferredfilename.md)
- [read(from:options:)](foundation/filewrapper/read(from:options:).md)
- [filename](foundation/filewrapper/filename.md)
- [File System Programming Guide](apple-archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/Introduction.md)
- [fileAttributes](foundation/filewrapper/fileattributes.md)

### Creating File Wrappers

- [init(path:)](foundation/filewrapper/init(path:).md)
- [init(directoryWithFileWrappers:)](foundation/filewrapper/init(directorywithfilewrappers:).md)
- [init(regularFileWithContents:)](foundation/filewrapper/init(regularfilewithcontents:).md)
- [init(symbolicLinkWithDestination:)](foundation/filewrapper/init(symboliclinkwithdestination:).md)
- [init(symbolicLinkWithDestinationURL:)](foundation/filewrapper/init(symboliclinkwithdestinationurl:).md)
- [init(serializedRepresentation:)](foundation/filewrapper/init(serializedrepresentation:).md)
