---
title: "setValue(_:forAttribute:)"
framework: opendirectory
role: symbol
role_heading: Instance Method
path: "opendirectory/odrecord/setvalue(_:forattribute:)"
---

# setValue(_:forAttribute:)

Sets the values of an attribute of the record.

## Declaration

```swift
func setValue(_ inValueOrValues: Any!, forAttribute inAttribute: String!) throws
```

## Parameters

- `inValueOrValues`: The value or values. Can be of type NSString or NSData, or an NSArray with elements of both types.
- `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

- [addValue(_:toAttribute:)](opendirectory/odrecord/addvalue(_:toattribute:).md)
- [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)
- [synchronize()](opendirectory/odrecord/synchronize().md)
- [values(forAttribute:)](opendirectory/odrecord/values(forattribute:).md)
