How to update my new code so that I can unarchive data from my old app in the App Store?

84 Views Asked by At

I have an app in the App Store that is quite old. I am trying to write an updated version. My original app archived and unarchived data as below. I cannot work out how to now access this data in my updated app.

- (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];
    }
0

There are 0 best solutions below