ios - plist data after an update -
i've created plist stores user's data in app such amount of coins, best score, clothes internal store , on. , now, 1 day before release, realized after updating app user's data lost. right?
if i'm not, how plists work? let's say, in version 1.0 of app have plist consists of amount of user's coins. decide add amount of diamonds plist, plist in version 2.0 consists of coins , diamonds. default value coins , diamonds 0.
so, user downloads 1 version, has 0 coins. plays while , earns 100 coins. updates app 2 version. happens plist in case? deleted, new 1 added instead , user have default 0 coins , 0 diamonds? or not updated @ all? or he'll still have 100 coins, 0 diamonds?
all in all, want know how other developers store user's data locally on device, without using external databases , on.
p.s. how create plist:
var paths = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true)[0] as! string var path = paths.stringbyappendingpathcomponent("userinfo.plist") var data = nsmutabledictionary(contentsoffile: path) var filemanager = nsfilemanager.defaultmanager() if (!(filemanager.fileexistsatpath(path))) { var bundle : nsstring = nsbundle.mainbundle().pathforresource("userinfo", oftype: "plist")! filemanager.copyitematpath(bundle string, topath: path, error:nil) }
and now, 1 day before release, realized after updating app user's data lost. right
no, not necessarily. if data stored in user defaults or file saved nonvolatile region of app's sandbox (such documents directory), merely upgrading app has no effect on it.
Comments
Post a Comment