file io - iOS photo extension finishContentEditingWithCompletionHandler: Unable to Save Changes -


my photo extension app has access both camera , photos. ok, when pressing done, can not save image.

code of standard completion handler:

- (void)finishcontenteditingwithcompletionhandler:(void (^)(phcontenteditingoutput *))completionhandler {     // update ui reflect editing has finished , output being rendered.      // render , provide output on background queue.     dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{         phcontenteditingoutput *output = [[phcontenteditingoutput alloc] initwithcontenteditinginput:self.input];          nserror* error = nil;          nsdata *renderedjpegdata = uiimagejpegrepresentation(filtered_ui_image, 1.0);         assert(renderedjpegdata != nil);         //bool written_well = [renderedjpegdata writetourl:output.renderedcontenturl atomically:yes];          bool written_well = [renderedjpegdata writetourl:output.renderedcontenturl options:nsdatawritingatomic error:&error];         assert(written_well);            // call completion handler commit edit photos.         completionhandler(output);     }); } 

renderedjpegdata not nil,
error nil, function [nsdata writetourl] successful,
written_well yes,

when debugging line-by-line, after block finishes, alert appears: enter image description here

output.renderedcontenturl /private/var/mobile/containers/data/pluginkitplugin/509c1a04-d414-4db7-b1e6-83c47fc88bc9/tmp/blah_blah_name.jpg

so, have permissions, debug shows no errors, can try detect cause of problem?

as of ios 10, adjustment data must have @ least 1 byte. breaking change ios 9, adjustment data can nil. i've tested on both ios 9 , ios 10 confirm.

additional documentation: https://developer.apple.com/reference/photos/phcontenteditingoutput/1518684-adjustmentdata

phcontenteditingoutput* output = [[phcontenteditingoutput alloc] initwithcontenteditinginput:self.input]; nsmutabledata* adjustmentdata = [nsmutabledata data]; uint8_t byte = 1; [adjustmentdata appendbytes:&byte length:1]; output.adjustmentdata = [[phadjustmentdata alloc] initwithformatidentifier:@"com.yourcompany.yourapp" formatversion:@"1.0f" data:adjustmentdata]; 

Comments