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

New init with default parameter that accepts another key #155

Closed
wants to merge 1 commit into from

Conversation

Maschina
Copy link
Contributor

Proposal to create a key with another key as default value.
This can be useful if you want to change the name of the key, but still provide support to migrate from the previous key name.

@sindresorhus
Copy link
Owner

It would be better if it accepted a string name as the default key (or previousName as a better name), since then you don't have to use two Defaults.Key. You just rename the existing Defaults.Key property name and then refer to the old UserDefaults name in the previousName parameter. That being said, I'm not even sure this init carries its own weight as you can generally just keep the UserDefaults string name while renaming the Defaults.Key property. I do that all the time. Much easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants