简体   繁体   中英

How to retrieve NSUserDefault value in upgraded app?

I am making video app. In that im creating multiple video path using

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *string = [NSString stringWithFormat:@"Video%@.mov",[NSDate date]];

NSString *videoPath =  [documentsDirectory stringByAppendingPathComponent:string];

NSURL *url = [NSURL fileURLWithPath:videoPath];

and exporting using AVAssetExportSession. After that, I am adding each exporter url into NSUserDefault

`

NSMutableArray *archiveArray = [[[NSUserDefaults standardUserDefaults] objectForKey:@"video"] mutableCopy];

NSData *personEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:outputURL];

[archiveArray addObject:personEncodedObject];

NSUserDefaults *userData = [NSUserDefaults standardUserDefaults];

[userData setObject:archiveArray forKey:@"video"];

[[NSUserDefaults standardUserDefaults] synchronize];

Now, problem is when I release new version of my app, I cant access previously stored video url in NSUserdefault.

NSUserdefault are maintain by iOS, you have no need to worry about in updating your app version,

If you have save some data in dafaults it will remains same in your updated version of app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM