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

Commit

Permalink
Add ability to set user defaults suite (#67)
Browse files Browse the repository at this point in the history
* Add ability to set user defaults suite.

* Update readme.
  • Loading branch information
shaundon authored Mar 21, 2024
1 parent 8555d28 commit b3882a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit b3882a7

Please sign in to comment.