---
title: "init(contentsOfMappedFile:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsdata/init(contentsofmappedfile:)"
---

# init(contentsOfMappedFile:)

Initializes a data object with the contents of the mapped file specified by a given path.

## Declaration

```swift
init?(contentsOfMappedFile path: String)
```

## Parameters

- `path`: The absolute path of the file from which to read data.

## Return Value

Return Value A data object initialized by reading into it the mapped file specified by path.

## See Also

### Reading Data from a File

- [init(contentsOfFile:)](foundation/nsdata/init(contentsoffile:).md)
- [init(contentsOfFile:options:)](foundation/nsdata/init(contentsoffile:options:).md)
- [NSData.ReadingOptions](foundation/nsdata/readingoptions.md)
- [dataWithContentsOfMappedFile(_:)](foundation/nsdata/datawithcontentsofmappedfile(_:).md)
