---
title: "addValue(_:toAttribute:)"
framework: opendirectory
role: symbol
role_heading: Instance Method
path: "opendirectory/odrecord/addvalue(_:toattribute:)"
---

# addValue(_:toAttribute:)

Adds a value to an attribute of the record.

## Declaration

```swift
func addValue(_ inValue: Any!, toAttribute inAttribute: String!) throws
```

## Parameters

- `inValue`: The value. Should be of type NSString or NSData.
- `inAttribute`: The attribute.

## Discussion

Discussion note: In Swift, this method returns Void 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

### Managing Record Attributes

- [recordDetails(forAttributes:)](opendirectory/odrecord/recorddetails(forattributes:).md)
- [recordName](opendirectory/odrecord/recordname.md)
- [recordType](opendirectory/odrecord/recordtype.md)
- [removeValues(forAttribute:)](opendirectory/odrecord/removevalues(forattribute:).md)
- [removeValue(_:fromAttribute:)](opendirectory/odrecord/removevalue(_:fromattribute:).md)
- [setValue(_:forAttribute:)](opendirectory/odrecord/setvalue(_:forattribute:).md)
- [synchronize()](opendirectory/odrecord/synchronize().md)
- [values(forAttribute:)](opendirectory/odrecord/values(forattribute:).md)
