---
title: Model()
framework: swiftdata
role: symbol
role_heading: Macro
path: swiftdata/model()
---

# Model()

Converts a Swift class into a stored model that’s managed by SwiftData.

## Declaration

```swift
@attached(member, conformances: Observable, PersistentModel, Sendable, names: named(_$backingData), named(persistentBackingData), named(schemaMetadata), named(init), named(_$observationRegistrar), named(_SwiftDataNoType), named(access), named(withMutation)) @attached(memberAttribute) @attached(extension, conformances: Observable, PersistentModel, Sendable) macro Model()
```

## Mentioned in

Preserving your app’s model data across launches

## Overview

Overview Annotate your model classes with the @Model macro to make them persistable. At build time, the macro expands to provide conformance to the PersistentModel and Observable protocols. @Model class RemoteImage {     var sourceURL: URL     var data: Data          init(sourceURL: URL, data: Data = Data()) {         self.sourceURL = sourceURL         self.data = data     } } For more information about defining models, see Preserving your app’s model data across launches.

## See Also

### Model definition

- [Attribute(_:originalName:hashModifier:)](swiftdata/attribute(_:originalname:hashmodifier:).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)
