# `GSUserDataProtocol setUserData:forKey:`

*Instance Method*

Sets or removes a persistent user-data value.

## Declaration

```swift
func setUserData(_ value: Any?, forKey key: String)
```

```objc
- (void) setUserData:(id) value forKey:(NSString *) key;
```

```python
setUserData_forKey_(value: object, key: str)
```

## Parameters

- `value` — A value that supports property-list encoding, or `nil` to remove the value.
- `key` — A stable, namespaced key identifying the value.

## Discussion

Passing `nil` as the value removes the user-data value.

