<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSManagedObjectContext/transactionAuthor",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSManagedObjectContext(py)transactionAuthor"
  },
  "title" : "transactionAuthor"
}
-->

# transactionAuthor

The author for the context that is used as an identifier in persistent history transactions.

```
var transactionAuthor: String? { get set }
```

## Discussion

Set a managed object context’s [`transactionAuthor`](/documentation/CoreData/NSManagedObjectContext/transactionAuthor) before saving it to differentiate among multiple call sites that modify the same context. Doing this records an [`author`](/documentation/CoreData/NSPersistentHistoryTransaction/author) in subsequent transactions.

```swift
func addColor(_ name: String, in context: NSManagedObjectContext) {
    let color = Color(context: context)
    color.name = name
    color.creationDate = Date()

    // set the transaction author
    context.transactionAuthor = "addColor"
    persistentContainer.saveContext(context)
    context.transactionAuthor = nil
}
```

Reset the context’s [`transactionAuthor`](/documentation/CoreData/NSManagedObjectContext/transactionAuthor) to nil after the save to prevent misattribution of future transactions.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)