---
title: "Attribute(_:originalName:hashModifier:)"
framework: swiftdata
role: symbol
role_heading: Macro
path: "swiftdata/attribute(_:originalname:hashmodifier:)"
---

# Attribute(_:originalName:hashModifier:)

Specifies the custom behavior that SwiftData applies to the annotated property when managing the owning class.

## Declaration

```swift
@attached(peer) macro Attribute(_ options: Schema.Attribute.Option..., originalName: String? = nil, hashModifier: String? = nil)
```

## Parameters

- `options`: A list of options to apply to the attached property to customize its behavior. For possible values, see doc://com.apple.SwiftData/documentation/SwiftData/Schema/Attribute/Option.
- `originalName`: The previous name of the attribute, if it’s different to the one in the current schema version. The default value is nil.
- `hashModifier`: A unique hash value that represents the most recent version of the attached property. The default value is nil.

## Mentioned in

Fetching and filtering time-based model changes Preserving your app’s model data across launches

## Overview

Overview The framework’s default behavior for managing a model class’s stored properties is suitable for most use cases. However, if you need to alter the persistence behavior of a particular property, annotate it with the @Attribute macro. For example, you may want to avoid conflicts in your model data by specifying that an attribute’s value is unique across all instances of that model. @Model class RemoteImage {     @Attribute(.unique) var sourceURL: URL     var data: Data          init(sourceURL: URL, data: Data = Data()) {         self.sourceURL = sourceURL         self.data = data     } }

## See Also

### Model definition

- [Model()](swiftdata/model().md)
- [Unique(_:)](swiftdata/unique(_:).md)
- [Index(_:)](swiftdata/index(_:)-74ia2.md)
- [Index(_:)](swiftdata/index(_:)-7d4z0.md)
- [Defining data relationships with enumerations and model classes](swiftdata/defining-data-relationships-with-enumerations-and-model-classes.md)
- [Relationship(_:deleteRule:minimumModelCount:maximumModelCount:originalName:inverse:hashModifier:)](swiftdata/relationship(_:deleterule:minimummodelcount:maximummodelcount:originalname:inverse:hashmodifier:).md)
- [Transient()](swiftdata/transient().md)
