我认为CoreData在这种情况下太重了。您可能希望使用plist来存储您的信息数据,.here是需要遵循的一些步骤。
- 从服务器加载映像后,创建一个字典来存储您想要的消息,并创建另一个字典来存储这些消息,并使用图像的url作为该字典的键。看起来可能是这样的:
imageUrl ={ lastSyncTime = xxxxxxxxxx,photoUploaded = 0,}
- 创建一个plist文件以保存此字典:
- (NSString *)filePath:(NSString *) fileName{ NSArray *paths =NSArray NSUserDomainMask,是);NSString *documentsDirectory = paths :0;返回documentsDirectory stringByAppendingPathComponent:fileName;}} [yourImageDictionary writeToFile:self filePath:@"imageInfo.plist“原子化:是];
- 随时阅读或写入您的plist文件:
if ([NSFileManager defaultManager fileExistsAtPath:self filePath:@"imageInfo.plist"]) { NSDictionary *imageInfo = [NSDictionary dictionaryWithContentsOfFile:self:@“imageInfo.plist”];