Search code examples
iosswiftnsuserdefaultsios-app-group

Remove information stored in App Groups


I am having trouble removing information when a user logs out of my application since adding in the app group.

This is the code I am trying to use for it.

let appDomain = NSBundle.mainBundle().bundleIdentifier
let prefs = NSUserDefaults(suiteName: GlobalVars.suiteName)
prefs!.removePersistentDomainForName(appDomain!)

How ever when executed it doesn't remove any of the information from the App Group so the user remains logged in.

Any help would be appreciated thank you.


Solution

  •          NSUserDefaults(suiteName: GlobalVars.suiteName)!.removeObjectForKey("USERNAME")
             NSUserDefaults(suiteName: GlobalVars.suiteName)!.removeObjectForKey("ISLOGGEDIN")
             NSUserDefaults(suiteName: GlobalVars.suiteName)!.synchronize()
    

    This solved my problem.