<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftData",
  "identifier" : "/documentation/SwiftData/PersistentIdentifier/isTemporary",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftData"
    ],
    "preciseIdentifier" : "s:9SwiftData20PersistentIdentifierV11isTemporarySbvp"
  },
  "title" : "isTemporary"
}
-->

# isTemporary

A Boolean value that indicates whether the identifier is temporary.

```
var isTemporary: Bool { get }
```

## Discussion

A temporary identifier is assigned to a model when it is first initialized.
Once you call [`save()`](/documentation/SwiftData/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)
```

---

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)