<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileWrapper/matchesContents(of:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileWrapper(im)matchesContentsOfURL:"
  },
  "title" : "matchesContents(of:)"
}
-->

# matchesContents(of:)

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

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

## Parameters

`url`

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

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> when the contents of the file wrapper match the contents of `url`, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## 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:)`](/documentation/Foundation/FileWrapper/init(url:options:)-70161) 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:)`](/documentation/Foundation/FileWrapper/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:

|File-wrapper type|Comparison determinants                  |
|-----------------|-----------------------------------------|
|Regular file     |Modification date and access permissions.|
|Directory        |Children (recursive).                    |
|Symbolic link    |Destination pathname.                    |

## See Also

[`fileAttributes`](/documentation/Foundation/FileWrapper/fileAttributes)

A dictionary of file attributes.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)