<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameSave",
  "identifier" : "/documentation/GameSave/GameSaveSyncedDirectory",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameSave"
    ],
    "preciseIdentifier" : "s:8GameSave0aB15SyncedDirectoryC"
  },
  "title" : "GameSaveSyncedDirectory"
}
-->

# GameSaveSyncedDirectory

A cloud-synced directory for game-save data.

```
class GameSaveSyncedDirectory
```

## Overview

To get an instance of the directory,
call [`openDirectory(containerIdentifier:)`](/documentation/GameSave/GameSaveSyncedDirectory/openDirectory(containerIdentifier:)),
which returns the directory for the iCloud container associated with the specified identifier.
Calling this method starts syncing the directory in the background on the specified container.
When the game needs to access the contents of the directory,
show a UI while the directory fully syncs
using the <doc://com.apple.documentation/documentation/SwiftUI/View/gameSaveSyncingAlert(directory:finishedLoading:)>
view extension if your app uses SwiftUI,
the [`finishSyncing(statusDisplay:)`](/documentation/GameSave/GameSaveSyncedDirectory/finishSyncing(statusDisplay:)-500el) method if your app uses UIKit,
or the [`finishSyncing(statusDisplay:)`](/documentation/GameSave/GameSaveSyncedDirectory/finishSyncing(statusDisplay:)-309nq) method if your app uses AppKit.

If you’re showing your own UI,
call the [`finishSyncing()`](/documentation/GameSave/GameSaveSyncedDirectory/finishSyncing()) method to wait for the directory to finish syncing.

After the directory is ready to use,
syncing pauses until you close the directory object or the object is deallocated.
To resume syncing during the game,
close and re-open the directory by calling [`close()`](/documentation/GameSave/GameSaveSyncedDirectory/close()) and then [`openDirectory(containerIdentifier:)`](/documentation/GameSave/GameSaveSyncedDirectory/openDirectory(containerIdentifier:)).

## Topics

### Accessing a directory

[`class func openDirectory(containerIdentifier: String?) -> GameSaveSyncedDirectory`](/documentation/GameSave/GameSaveSyncedDirectory/openDirectory(containerIdentifier:))

Requests an instance of the game-save directory.

[`enum State`](/documentation/GameSave/GameSaveSyncedDirectory/State-swift.enum)

The state of the directory.

[`var state: GameSaveSyncedDirectory.State`](/documentation/GameSave/GameSaveSyncedDirectory/state-swift.property)

The state that the game-save directory is in.

### Syncing a directory

[`func finishSyncing() async`](/documentation/GameSave/GameSaveSyncedDirectory/finishSyncing())

Waits for the directory sync to complete, without showing any user interface.

[`func finishSyncing(statusDisplay: NSWindow) async`](/documentation/GameSave/GameSaveSyncedDirectory/finishSyncing(statusDisplay:)-309nq)

Waits for the directory sync to complete, showing the sync’s progress in a modal alert.   

[`func finishSyncing(statusDisplay: UIWindow) async`](/documentation/GameSave/GameSaveSyncedDirectory/finishSyncing(statusDisplay:)-500el)

Waits for the directory sync to complete, showing the sync’s progress in a modal alert.   

### Resolving conflicts

[`class Version`](/documentation/GameSave/GameSaveSyncedDirectory/Version)

A representation of a version of the directory.

[`func resolveConflicts(with: GameSaveSyncedDirectory.Version)`](/documentation/GameSave/GameSaveSyncedDirectory/resolveConflicts(with:))

Indicates that you resolved a conflict.

### Finishing with a directory

[`func triggerPendingUpload() async -> Bool`](/documentation/GameSave/GameSaveSyncedDirectory/triggerPendingUpload())

Triggers an upload of the directory for any changes that were pending.

[`func close()`](/documentation/GameSave/GameSaveSyncedDirectory/close())

Closes the directory, and resumes syncing the directory to the cloud.

## Relationships

### Conforms To

[`Observable`](/documentation/Observation/Observable)

[`Copyable`](/documentation/Swift/Copyable)

[`Escapable`](/documentation/Swift/Escapable)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Identifiable`](/documentation/Swift/Identifiable)

[`Equatable`](/documentation/Swift/Equatable)

---

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)