Contents

init(for:identifier:)

Creates an EntityIdentifier representing an instance of the specified entity type backed by the specified identifier value.

Declaration

init<Entity>(for entityType: Entity.Type, identifier: Entity.ID) where Entity : AppEntity

Parameters

  • entityType:

    The type of the entity

  • identifier:

    The identifier value for the entity

Discussion

For entity types adopting _SyncableEntity, this initializer extracts the stable ID:

  • Passthrough case: If the ID is already stable (like UUID), it’s used as both local and stable ID

  • Mapped case: If the ID uses _SyncableEntityIdentifier, the stable ID is extracted from the wrapper

  • Custom identifier case: If the ID conforms to _SyncableEntityIdentifierProviding, the stable ID is extracted via stableIdentifierString

See Also

Creating an entity identifier