Skip to content

Comments

Add support for UserDefaults suite name#18

Merged
thejohnlima merged 3 commits intomainfrom
feature/add_defaults_suite
Jan 16, 2026
Merged

Add support for UserDefaults suite name#18
thejohnlima merged 3 commits intomainfrom
feature/add_defaults_suite

Conversation

@thejohnlima
Copy link
Owner

Instead of using UserDefaults.default, these changes add support to create an instance using the suite name, usually required, for example, when working with App Groups to make the communication between the main app and Widgets.

How to use

import LMStorage

struct MyDefaults: LMDefaults {
  static var suiteName: String? = "com.myApp.example"

  enum Keys: String {
    case currentUser
    case accessToken
    case haveSeenOnboarding
    case selectedMovie
  }
}
MyDefaults.set(item.title, forKey: .selectedMovie)
let movie = MyDefaults.value(forKey: .selectedMovie) as? String

@sonarqubecloud
Copy link

@thejohnlima thejohnlima merged commit 447254c into main Jan 16, 2026
3 checks passed
@thejohnlima thejohnlima deleted the feature/add_defaults_suite branch January 16, 2026 00:02
@thejohnlima thejohnlima added the enhancement New feature or request label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant