如何将数据附加到NSKeyedArchive? [英] How to append data to NSKeyedArchive?
本文介绍了如何将数据附加到NSKeyedArchive?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在读取这样的文件:
I'm reading a file like so:
NSData *data = [NSData dataWithContentsOfFile:myPath];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
NSData *imgData = [unarchiver decodeObjectForKey:@"myimage"];
if (imgData != nil) {
self.image = [[NSImage alloc]initWithData:imgData];
}else{
self.image = nil;
}
[unarchiver finishDecoding];
[unarchiver release];
我想做的是将键@"myimage"的图像数据附加到同一文件(如果不存在).
What I'd like to do is to append image data for key @"myimage" to the same file if it doesn't exist.
如何处理?
推荐答案
似乎没有办法附加"到NSKeyedArchive,因此我只是在添加了额外数据的情况下重新创建了它,并覆盖了原始文件.
It seems that there's no way to "append" to NSKeyedArchive, so I just re-created it with the extra data added and have written over the original file.
这篇关于如何将数据附加到NSKeyedArchive?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文