---
title: "setValue(_:forProperty:error:)"
framework: addressbook
role: symbol
role_heading: Instance Method
path: "addressbook/abrecord/setvalue(_:forproperty:error:)"
---

# setValue(_:forProperty:error:)

Sets the value of a given property for a record, returning error information.

## Declaration

```swift
func setValue(_ value: Any!, forProperty property: String!, error: ()) throws
```

## Parameters

- `value`: The value to set for property.
- `property`: The property whose value will be set.
- `error`: A pointer to an error object that is set to an doc://com.apple.documentation/documentation/Foundation/NSError instance if an error occurs.

## Discussion

Discussion The type of the value must match the property’s type (see Property Types for a list of possible property types). If property is nil or if value is not of the correct type, this method raises an exception. If property is a multivalue list property, this method checks to see if the values in the multivalue list are the same type. If the multivalue list contains mixed types, the value will not be set successfully. For a list of the available properties, see Accessing Address Book Records in Address Book Programming Guide for Mac. 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

### Retrieving and Setting Values

- [removeValue(forProperty:)](addressbook/abrecord/removevalue(forproperty:).md)
- [setValue(_:forProperty:)](addressbook/abrecord/setvalue(_:forproperty:).md)
- [value(forProperty:)](addressbook/abrecord/value(forproperty:).md)
