---
title: "model(for:)"
framework: swiftdata
role: symbol
role_heading: Instance Method
path: "swiftdata/modelcontext/model(for:)"
---

# model(for:)

Returns the persistent model for the specified identifier.

## Declaration

```swift
func model(for persistentModelID: PersistentIdentifier) -> any PersistentModel
```

## Parameters

- `persistentModelID`: The identifier of the model to fetch. For more information, see doc://com.apple.SwiftData/documentation/SwiftData/PersistentIdentifier.

## Return Value

Return Value The identified persistent model, if known to the context; otherwise, an unsaved model with its persistentModelID property set to persistentModelID.

## See Also

### Fetching models

- [fetch(_:)](swiftdata/modelcontext/fetch(_:).md)
- [fetch(_:batchSize:)](swiftdata/modelcontext/fetch(_:batchsize:).md)
- [fetchCount(_:)](swiftdata/modelcontext/fetchcount(_:).md)
- [FetchDescriptor](swiftdata/fetchdescriptor.md)
- [FetchResultsCollection](swiftdata/fetchresultscollection.md)
- [enumerate(_:batchSize:allowEscapingMutations:block:)](swiftdata/modelcontext/enumerate(_:batchsize:allowescapingmutations:block:).md)
- [registeredModel(for:)](swiftdata/modelcontext/registeredmodel(for:).md)
