I'm trying to take a picture and save it with a name, but I do not know if I'm doing it right.
What I want to do is to send it to a server through a WebService, but I can not make the image save with the name I'm placing it.
I am developing it in Xcode 9 and Swift 4.
This is my code to open the camera:
func openCamera(){
if UIImagePickerController.isSourceTypeAvailable(.camera){
if((UIImagePickerController.availableCaptureModes(for: .rear)) != nil){
imagePicker.allowsEditing = false;
imagePicker.sourceType = .camera;
imagePicker.cameraCaptureMode = .photo;
present(imagePicker, animated: true, completion: nil);
}
}
}
extension ClassViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let imageName = "img_\(Date().timeIntervalSince1970).jpg";
print("Tag: Nombre de la imagen es: ", imageName);
if let imagenSeleccionada:UIImage = info[UIImagePickerControllerOriginalImage] as? UIImage{
ImgFotografia.image = imagenSeleccionada;
UIImageWriteToSavedPhotosAlbum(imagenSeleccionada, nil, nil, nil);
}
imagePicker.dismiss(animated: true, completion: nil);
}
}