Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
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
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