Skip to content

Instantly share code, notes, and snippets.

@dougdiego
dougdiego / MigrateDefaults.swift
Last active December 22, 2022 09:41
Migrate NSUserDefaults to App Groups - Swift
View MigrateDefaults.swift
func migrateUserDefaultsToAppGroups() {
// User Defaults - Old
let userDefaults = NSUserDefaults.standardUserDefaults()
// App Groups Default - New
let groupDefaults = NSUserDefaults(suiteName: "group.myGroup")
// Key to track if we migrated
let didMigrateToAppGroups = "DidMigrateToAppGroups"