---
title: "add(_:error:)"
framework: addressbook
role: symbol
role_heading: Instance Method
path: "addressbook/abaddressbook/add(_:error:)"
---

# add(_:error:)

Adds an ABPerson or ABGroup record to the Address Book database.

## Declaration

```swift
func add(_ record: ABRecord!, error: ()) throws
```

## Parameters

- `record`: The record to add.
- `error`: A pointer to an error object that is set to an NSError instance if an error occurs.

## Discussion

Discussion If the record argument is nil, this method raises an exception. Your changes are not committed until you call the save() method. It is more efficient to use the  ABRecord method init(addressBook:) when possible. 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

### Adding and Removing Records

- [add(_:)](addressbook/abaddressbook/add(_:).md)
- [remove(_:error:)](addressbook/abaddressbook/remove(_:error:).md)
- [remove(_:)](addressbook/abaddressbook/remove(_:).md)
