Skip to content

Commit

Permalink
Make delegate Settings constructors public
Browse files Browse the repository at this point in the history
  • Loading branch information
russhwolf committed Jun 11, 2018
1 parent 29b7998 commit f399012
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ On iOS, the factory can be instantiated without passing any parameter
val settings = factory.create("my_settings_name")

On both platforms, the name argument to `Factory.create()` can be omitted, and a platform-specific default will be used.

Alternatively, you can create a `Settings` instance by passing the platform-specific delegate class that `Settings` wraps around. On Android,

val delegate: SharedPreferences = ...
val settings: Settings = Settings(delegate)

And on iOS,

val delegate: NSUserDefaults = ...
val settings: Settings = Settings(delegate)

Once the `Settings` instance is created, you can store values by calling the various `putXXX()` methods, or their operator shortcuts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences
import android.preference.PreferenceManager

actual class Settings private constructor(private val delegate: SharedPreferences) {
actual class Settings public constructor(private val delegate: SharedPreferences) {

actual class Factory(context: Context) {
private val appContext = context.applicationContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.russhwolf.settings
import platform.Foundation.NSUserDefaults
import platform.Foundation.NSBundle

actual class Settings constructor(private val delegate: NSUserDefaults) {
actual class Settings public constructor(private val delegate: NSUserDefaults) {

actual class Factory() {
actual fun create(name: String?): Settings {
Expand Down
2 changes: 1 addition & 1 deletion sample/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f399012

Please sign in to comment.