# `GSBaseObject attributeForKey:`

*Instance Method*

The value for an attribute key, or `nil` if no value is set.

## Declaration

```swift
func attribute(forKey key: GSShapeKey) -> Any?
```

```objc
- (id) attributeForKey:(GSShapeKey) key;
```

```python
attributeForKey_(key: GSShapeKey) -> object
```

## See Also

### Attributes

- [`GSBaseObject.attributes`](/Core/GlyphsCore/GSBaseObject/attributes) — Additional values associated with the object.
- [`GSBaseObject.countOfAttributes`](/Core/GlyphsCore/GSBaseObject/countOfAttributes) — The number of attributes.
- [`GSBaseObject setAttribute:forKey:`](/Core/GlyphsCore/GSBaseObject/setAttribute:forKey:) — Sets or removes an attribute.
- [`GSBaseObject setAttributes:format:`](/Core/GlyphsCore/GSBaseObject/setAttributes:format:) — Replaces all attributes using values encoded for a file format version.
- [`GSBaseObject setAttributesFast:format:`](/Core/GlyphsCore/GSBaseObject/setAttributesFast:format:) — Replaces all attributes without registering undo or notifying the parent.
- [`GSBaseObject removeAttributeForKey:`](/Core/GlyphsCore/GSBaseObject/removeAttributeForKey:) — Removes an attribute.

