Cómo obtener la URL de una imagen recién agregada en PHPhotoLibrary
Estoy usando el UIImagePickerController en dos casos
para seleccionar una imagen existente en la Biblioteca de fotostomar una nueva fotoEn el primer caso, cuando elijo una imagen de la biblioteca, puedo obtener fácilmente la URL en el método delegado:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Get the URL
NSURL *url = [info valueForKey:UIImagePickerControllerReferenceURL];
...
}
Pero cuando tomo una nueva foto, la imagen aún no está en la biblioteca de fotos y aún no tiene URL. Entonces, primero necesito agregar la imagen en la Biblioteca. Pero entonces, ¿cómo obtener la URL del nuevo activo?
Aquí está mi código para agregar la imagen en la 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 ?
...
}
];
}