---
title: "init(regularFileWithContents:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/filewrapper/init(regularfilewithcontents:)"
---

# init(regularFileWithContents:)

Initializes the receiver as a regular-file file wrapper.

## Declaration

```swift
init(regularFileWithContents contents: Data)
```

## Parameters

- `contents`: Contents of the file.

## Return Value

Return Value Initialized regular-file file wrapper containing contents.

## Discussion

Discussion After initialization, the file wrapper is not associated with a file-system node until you save it using write(to:options:originalContentsURL:). The file wrapper is initialized with open permissions: anyone can write to or read the file wrapper.

## See Also

### Related Documentation

- [preferredFilename](foundation/filewrapper/preferredfilename.md)
- [filename](foundation/filewrapper/filename.md)
- [fileAttributes](foundation/filewrapper/fileattributes.md)
- [regularFileContents](foundation/filewrapper/regularfilecontents.md)

### Creating File Wrappers

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