Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Add ability to set user defaults suite #67

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ Zephyr.debugEnabled = true // Must be called before sync(_:)
Zephyr.sync()
```

**Use a specific `UserDefaults` suite**
```swift
if let suite = UserDefaults(suiteName: "group.com.example.app-name") {
Zephyr.setUserDefaultsSuite(to: suite)
}
```

### Sample App

Please ignore the Sample App as I did not add any demo code in the Sample App. It's only in this repo to add support for Carthage.
Expand Down
9 changes: 9 additions & 0 deletions Sources/Zephyr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@ private extension Zephyr {

}

/// Set Zephyr to use a different UserDefaults suite than `.standard`.
///
/// - Parameters:
/// - to: A `UserDefaults` suite.
public static func setUserDefaultsSuite(to suite: UserDefaults) {
shared.userDefaults = suite
printStatus(status: "Updated UserDefaults suite.")
}

}

// MARK: - Synchronizers
Expand Down