我正在开发一个照片编辑扩展应用程序,我希望它能够将有关更改的信息保存到 PHAdjustmentData 中,以便用户以后可以修改这些更改。我将所有需要的数据保存到 PHAdjustmentData 中,但是,下次我编辑图像时 - PHAdjustmentData 为零。这是一个示例代码:
@property (strong, nonatomic) PHContentEditingOutput *output;
- (void)startContentEditingWithInput:(PHContentEditingInput *)contentEditingInput placeholderImage:(UIImage *)placeholderImage
{
self.output = [[PHContentEditingOutput alloc] initWithContentEditingInput:contentEditingInput];
// here contentEditingInput.adjustmentData is always nil
}
- (void)finishContentEditingWithCompletionHandler:(void (^)(PHContentEditingOutput *))completionHandler
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:@"value1" forKey:@"key1"];
[dict setObject:@"value2" forKey:@"key2"];
NSData *adjData = [NSKeyedArchiver archivedDataWithRootObject:dict];
PHAdjustmentData *phAdjData = [[PHAdjustmentData alloc] initWithFormatIdentifier:@"ident" formatVersion:@"1.0" data:adjData];
self.output.adjustmentData = phAdjData;
NSData *data = UIImageJPEGRepresentation(result, 1.0);
[data writeToURL:self.output.renderedContentURL options:NSDataWritingAtomic error:nil];
completionHandler(self.output);
}
如何正确保存调整数据,以便下次用户编辑图像时可以访问它?谢谢!