---
title: "SecTransformSetAttributeAction(_:_:_:_:)"
framework: security
role: symbol
role_heading: Function
path: "security/sectransformsetattributeaction(_:_:_:_:)"
---

# SecTransformSetAttributeAction(_:_:_:_:)

Requests a callback when an attribute is set.

## Declaration

```swift
func SecTransformSetAttributeAction(_ ref: SecTransformImplementationRef, _ action: CFString, _ attribute: SecTransformStringOrAttribute?, _ newAction: @escaping SecTransformAttributeActionBlock) -> CFError?
```

## Parameters

- `ref`: A doc://com.apple.security/documentation/Security/SecTransformImplementationRef that is bound to an instance of a custom transform.
- `action`: The behavior to be set. Use doc://com.apple.security/documentation/Security/kSecTransformActionAttributeNotification to add a block that is called when an attribute is set. If the name is NULL, then the supplied block is called for all set attributes except for ones that have a specific block as a handler. Use doc://com.apple.security/documentation/Security/kSecTransformActionAttributeValidation to add a block that is called to validate the input to an attribute.
- `attribute`: The name of the attribute that will be handled. An attribute reference may also be given here. A NULL value indicates that the supplied action is for all attributes.
- `newAction`: A doc://com.apple.security/documentation/Security/SecTransformAttributeActionBlock which implements the behavior.

## Return Value

Return Value An error on failure, or NULL on success. In Objective-C, call the CFRelease function to free the error’s memory when you are done with it.

## Discussion

Discussion The kSecTransformActionProcessData action used with the SecTransformSetDataAction(_:_:_:) function is a special case of a SecTransformSetAttributeAction(_:_:_:_:) action. If this is called on the input attribute then it will overwrite any kSecTransformActionProcessData action. You may call this function multiple times for either a named attribute or for all attributes when the attribute parameter is NULL. The last call takes precedence.
