Como obter o URL de uma imagem adicionada no PHPhotoLibrary
Estou usando o UIImagePickerController em dois casos
para selecionar uma imagem existente na Biblioteca de fotostirar uma nova fotoNo primeiro caso, quando escolho uma imagem da biblioteca, posso obter facilmente o URL no método delegate:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Get the URL
NSURL *url = [info valueForKey:UIImagePickerControllerReferenceURL];
...
}
Mas, quando tiro uma nova foto, a imagem ainda não está na biblioteca de fotos e ainda não tem URL. Então, primeiro preciso adicionar a imagem na Biblioteca. Mas então, como obter o URL do novo ativo?
Aqui está o meu código para adicionar a imagem na Biblioteca de Fotos
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Get the image
UIImage *image = [info objectF,orKey:UIImagePickerControllerOriginalImage];
// Add the image in the library
[[PHPhotoLibrary sharedPhotoLibrary]
performChanges:^
{
// Request creating an asset from the image.
PHAssetChangeRequest *createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
// Get the URL of the new asset here ?
...
}
completionHandler:^(BOOL success, NSError *error)
{
if (!success) { ...; return; }
// Get the URL of the new asset here ?
...
}
];
}