<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURL/promisedItemResourceValues(forKeys:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURL(im)promisedItemResourceValuesForKeys:error:"
  },
  "title" : "promisedItemResourceValues(forKeys:)"
}
-->

# promisedItemResourceValues(forKeys:)

Returns the resource values for the properties identified by specified array of keys.

```
func promisedItemResourceValues(forKeys keys: [URLResourceKey]) throws -> [URLResourceKey : Any]
```

## Parameters

`keys`

An array of names of URL resource properties.

## Return Value

A dictionary of resource values indexed by key.

## Discussion

This method behaves identically to [`resourceValues(forKeys:)`](/documentation/Foundation/NSURL/resourceValues(forKeys:)), but works on promised items. A promised item is not guaranteed to have its contents in the file system until you use a file coordinator to perform a coordinated read on its URL, which causes the contents to be downloaded or otherwise generated. Promised item URLs are returned by various APIs, including:

- A metadata query using either the [`NSMetadataQueryUbiquitousDataScope`](/documentation/Foundation/NSMetadataQueryUbiquitousDataScope) or [`NSMetadataQueryUbiquitousDocumentsScope`](/documentation/Foundation/NSMetadataQueryUbiquitousDocumentsScope) scopes
- The contents of the directory returned by the file manager’s `URLForUbiquitousContainerIdentifier:`
- The URL inside the accessor block of a coordinated read or write operation that used the [`immediatelyAvailableMetadataOnly`](/documentation/Foundation/NSFileCoordinator/ReadingOptions/immediatelyAvailableMetadataOnly), [`forDeleting`](/documentation/Foundation/NSFileCoordinator/WritingOptions/forDeleting), [`forMoving`](/documentation/Foundation/NSFileCoordinator/WritingOptions/forMoving), or [`contentIndependentMetadataOnly`](/documentation/Foundation/NSFileCoordinator/WritingOptions/contentIndependentMetadataOnly) options

You must use this method instead of `resourceValuesForKeys:error:` for any URLs returned by these methods.

This method works for any resource value that is not tied to the item’s contents. Some keys, like [`contentAccessDateKey`](/documentation/Foundation/URLResourceKey/contentAccessDateKey) or [`generationIdentifierKey`](/documentation/Foundation/URLResourceKey/generationIdentifierKey), do not return valid values. If you use one of these keys, the method returns <doc://com.apple.documentation/documentation/Swift/true>, but the value returns `nil`.

> 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`.

## See Also

[`-  resourceValuesForKeys:error:`](/documentation/Foundation/NSURL/resourceValues(forKeys:))

Returns the resource values for the properties identified by specified array of keys.



---

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)