<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileManager/attributesOfItem(atPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)attributesOfItemAtPath:error:"
  },
  "title" : "attributesOfItem(atPath:)"
}
-->

# attributesOfItem(atPath:)

Returns the attributes of the item at a given path.

```
func attributesOfItem(atPath path: String) throws -> [FileAttributeKey : Any]
```

## Parameters

`path`

The path of a file or directory.

## Return Value

A dictionary object that describes the attributes (file, directory, symlink, and so on) of the file specified by `path` (or `nil` if an error occurred in Objective-C). The keys in the dictionary are described in `File Attribute Keys`.

## Discussion

If the item at the path is a symbolic link—that is, the value of the [`type`](/documentation/Foundation/FileAttributeKey/type) key in the attributes dictionary is [`typeSymbolicLink`](/documentation/Foundation/FileAttributeType/typeSymbolicLink)—you can use the [`destinationOfSymbolicLink(atPath:)`](/documentation/Foundation/FileManager/destinationOfSymbolicLink(atPath:)) method to retrieve the path of the item pointed to by the link. You can also use the [`resolvingSymlinksInPath`](/documentation/Foundation/NSString/resolvingSymlinksInPath) method of [`NSString`](/documentation/Foundation/NSString) to resolve links in the path before retrieving the item’s attributes.

As a convenience, [`NSDictionary`](/documentation/Foundation/NSDictionary) provides a set of methods (declared as a category on [`NSDictionary`](/documentation/Foundation/NSDictionary)) for quickly and efficiently obtaining attribute information from the returned dictionary: [`fileGroupOwnerAccountName()`](/documentation/Foundation/NSDictionary/fileGroupOwnerAccountName()), [`fileModificationDate()`](/documentation/Foundation/NSDictionary/fileModificationDate()), [`fileOwnerAccountName()`](/documentation/Foundation/NSDictionary/fileOwnerAccountName()), [`filePosixPermissions()`](/documentation/Foundation/NSDictionary/filePosixPermissions()), [`fileSize()`](/documentation/Foundation/NSDictionary/fileSize()), [`fileSystemFileNumber()`](/documentation/Foundation/NSDictionary/fileSystemFileNumber()), [`fileSystemNumber()`](/documentation/Foundation/NSDictionary/fileSystemNumber()), and [`fileType()`](/documentation/Foundation/NSDictionary/fileType()).

### Discussion

> Handling Errors in Swift:
> In Swift, this method returns a nonoptional result 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](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html) in [The Swift Programming Language](https://docs.swift.org/swift-book/) and `About Imported Cocoa Error Parameters`.

---

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)