How to remove all data by a suite name from UserDefaults in Swift?

前端 未结 3 866
陌清茗
陌清茗 2021-01-24 04:45

I have created user defaults with names below,

let prefs1 = UserDefaults.init(suiteName: \"UserAccount\")
let prefs2 = UserDefaults.init(suiteName: \"UserInfo\")         


        
3条回答
  •  执念已碎
    2021-01-24 05:51

    func removePersistentDomain(forName domainName: String)

    https://developer.apple.com/documentation/foundation/userdefaults/1417339-removepersistentdomain

    Calling this method is equivalent to initializing a user defaults object with init(suiteName:) passing domainName, and calling the removeObject(forKey:) method on each of its keys.

提交回复
热议问题