I working on sharing array of images from gallery using share extension. i can get image inside share extension using
- (void)getImageFromExtension:(NSExtensionItem *)extensionItem
{
for(NSItemProvider *attachment in extensionItem.attachments)
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if([attachment hasItemConformingToTypeIdentifier:(NSString *)kUTTypeImage])
{
[attachment loadItemForTypeIdentifier:(NSString *)kUTTypeImage options:nil completionHandler:^(id<NSSecureCoding> item, NSError *error) {
NSURL *image = (NSURL *)item;
if(error)
{
NSLog(@"Error retrieving image");
} else {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"*** ### %@",[UIImage imageWithData:[NSData dataWithContentsOfURL:image]]);
});
}
}];
}
});
}
}
What i actually need is, i need to pass image url to container applciation. But not able to get image from that URL. The url format is file:///var/mobile/Media/DCIM/101APPLE/IMG_1705.JPG
The data from this url is always null. how to get the image from this URL?