<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSFontDescriptor/object(forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFontDescriptor(im)objectForKey:"
  },
  "title" : "object(forKey:)"
}
-->

# object(forKey:)

Returns the font attribute specified by the given key.

```
func object(forKey attribute: NSFontDescriptor.AttributeName) -> Any?
```

## Parameters

`attribute`

The font attribute key.

## Return Value

The font attribute corresponding to `anAttribute`. For valid values of `anAttribute`, see `Font Attributes`.

## See Also

[`fontDescriptorWithFontAttributes:`](/documentation/AppKit/NSFontDescriptor/fontDescriptorWithFontAttributes:)

Returns a font descriptor with a dictionary of attributes.

[`symbolicTraits`](/documentation/AppKit/NSFontDescriptor/symbolicTraits-swift.property)

A bit mask that describes the traits of the receiver.



---

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)