iOS: What are the possible options to Reset an iOS apps Data without requiring a reinstall? -


this ios 101 question , feel ass not knowing answer :-) question - how reset ios app state when first installed? app stores content in nsuserdefaults , plists. appears excessive have ask user delete , reinstall app.

what possible options available aside asking user reinstall app (which makes me kinda un-innovative :-) )

this particular app used nsuserdefaults , plists store data. while come creative solutions i'd appreciate clues other situations (i.e. data in core data , .plists)

also if feature needs implemented in app code, appreciate suggestions on elegant solution it.

thanks!

delete files sandbox:

nsstring *p = [[[nsbundle mainbundle] bundlepath] stringbydeletinglastpathcomponent]; (nsstring *fname in @[ @"tmp", @"library", @"documents", @"caches", @"preferences" ]) {     nsstring *path = [p stringbyappendingpathcomponent:fname];     [[nsfilemanager defaultmanager] removeitematpath:path error:null]; } 

alternative way resetting user defaults only:

nsdictionary *drepr = [[nsuserdefaults standarduserdefaults] dictionaryrepresentation]; (nsstring *key in drepr) {     [[nsuserdefaults standarduserdefaults] removeobjectforkey:key]; }  [[nsuserdefaults standarduserdefaults] synchronize]; [nsuserdefaults resetstandarduserdefaults]; 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -