One Logo Pool Ball
SwiftData · IOS API REFERENCE

PersistentIdentifier

struct · iOS 16.0+ · SDK 27.1

struct PersistentIdentifier

A type that describes the aggregate identity of a SwiftData model. > Note: Decoded ``PersistentIdentifier`` and identifiers created by the ``DefaultStore`` are not considered equivalent.

Members (4)

get · iOS 16.0+

storeIdentifier

TypeScript
get storeIdentifier(): (string) | null
Swift declaration
var storeIdentifier: String? { get }

The identifier of the store that contains the associated model.

get · iOS 16.0+

entityName

TypeScript
get entityName(): string
Swift declaration
var entityName: String { get }

The entity name for the associated model.

get · iOS 27.0+

isTemporary

TypeScript
get isTemporary(): boolean
Swift declaration
var isTemporary: Bool { get }

A Boolean value that indicates whether the identifier is temporary. A temporary identifier is assigned to a model when it is first initialized. Once you call ``ModelContext/save()``, the model receives a permanent identifier. Temporary identifiers should not be persisted or used to create durable maps to a model. Temporary identifiers are only valid until an object is persisted, and must be remapped to the permanent identifier once a model is saved. ```swift if model.persistentModelID.isTemporary { try modelContext.save() } let data = try JSONEncoder().encode(model.persistentModelID) ```

get · iOS 16.0+

id

TypeScript
get id(): PersistentIdentifier_ID
Swift declaration
let id: PersistentIdentifier.ID

The value that uniquely identifies the associated model within the containing store.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

PersistentIdentifier.identifier(for:entityName:primaryKey:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

All SwiftData types →