---
title: "attributesOfItem(atPath:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filemanager/attributesofitem(atpath:)"
---

# attributesOfItem(atPath:)

Returns the attributes of the item at a given path.

## Declaration

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

## Parameters

- `path`: The path of a file or directory.

## Return Value

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

Discussion If the item at the path is a symbolic link—that is, the value of the type key in the attributes dictionary is typeSymbolicLink—you can use the destinationOfSymbolicLink(atPath:) method to retrieve the path of the item pointed to by the link. You can also use the resolvingSymlinksInPath method of NSString to resolve links in the path before retrieving the item’s attributes. As a convenience, NSDictionary provides a set of methods (declared as a category on NSDictionary) for quickly and efficiently obtaining attribute information from the returned dictionary: fileGroupOwnerAccountName(), fileModificationDate(), fileOwnerAccountName(), filePosixPermissions(), fileSize(), fileSystemFileNumber(), fileSystemNumber(), and fileType(). Discussion note: 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 in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Getting and setting attributes

- [componentsToDisplay(forPath:)](foundation/filemanager/componentstodisplay(forpath:).md)
- [displayName(atPath:)](foundation/filemanager/displayname(atpath:).md)
- [attributesOfFileSystem(forPath:)](foundation/filemanager/attributesoffilesystem(forpath:).md)
- [setAttributes(_:ofItemAtPath:)](foundation/filemanager/setattributes(_:ofitematpath:).md)
