提问人:MPD 提问时间:12/7/2021 更新时间:12/7/2021 访问量:75
如何更新我的新代码,以便我可以在 App Store 中取消存档旧 App 中的数据?
How to update my new code so that I can unarchive data from my old app in the App Store?
问:
我在 App Store 中有一个很旧的应用程序。我正在尝试编写更新版本。我的原始应用程序存档和未存档的数据如下。我现在无法弄清楚如何在更新的应用程序中访问这些数据。
- (void)saveGG
{
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:givens forKey:@"Present"];
[archiver finishEncoding];
[data writeToFile:[self dataFilePath] atomically:YES];
}
- (void)loadGG
{
NSString *path = [self dataFilePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:path])
{
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
gifts = [unarchiver decodeObjectForKey:@"Present"];
[unarchiver finishDecoding];
}
else
{
gifts = [[NSMutableArray alloc] initWithCapacity:20];
}
答: 暂无答案
评论