---
title: "matchesContents(of:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filewrapper/matchescontents(of:)"
---

# matchesContents(of:)

Indicates whether the contents of a file wrapper matches a directory, regular file, or symbolic link on disk.

## Declaration

```swift
func matchesContents(of url: URL) -> Bool
```

## Parameters

- `url`: URL of the file-system node with which to compare the file wrapper.

## Return Value

Return Value true when the contents of the file wrapper match the contents of url, false otherwise.

## Discussion

Discussion The contents of files are not compared; matching of regular files is based on file modification dates. For a directory, children are compared against the files in the directory, recursively. Because children of directory file wrappers are not read immediately by the init(url:options:) method unless the NSFileWrapperReadingImmediate reading option is used, even a newly-created directory file wrapper might not have the same contents as the directory on disk. You can use this method to determine whether the file wrapper’s contents in memory need to be updated. If the file wrapper needs updating, use the read(from:options:) method with the NSFileWrapperReadingImmediate reading option. This table describes which attributes of the file wrapper and file-system node are compared to determine whether the file wrapper matches the node on disk:  |   |   |   |

## See Also

### Related Documentation

- [fileAttributes](foundation/filewrapper/fileattributes.md)

### Updating File Wrappers

- [needsToBeUpdated(fromPath:)](foundation/filewrapper/needstobeupdated(frompath:).md)
- [update(fromPath:)](foundation/filewrapper/update(frompath:).md)
- [read(from:options:)](foundation/filewrapper/read(from:options:).md)
