I'm working on a photo-editing extension app, and I want it to be able to save the information about the changes made into the PHAdjustmentData, so that user can modify those changes later. I save all the required data into PHAdjustmentData, however, next time I edit the image - PHAdjustmentData is nil. Here is a sample code:
@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);
}
How do I save the adjustment data properly, so that I can access it next time user edits the image? Thanks!