I started learning the iOS development using swift and Xcode today. I am absolute beginner to iOS development. Now I am trying to open an image picker. But when I fire the event to open image picker interacting with UI, it is giving me the following error:
libsystem_kernel.dylib`__abort_with_payload:
0x1081980a0 <+0>: movl $0x2000209, %eax ; imm = 0x2000209
0x1081980a5 <+5>: movq %rcx, %r10
0x1081980a8 <+8>: syscall
-> 0x1081980aa <+10>: jae 0x1081980b4 ; <+20>
0x1081980ac <+12>: movq %rax, %rdi
0x1081980af <+15>: jmp 0x108191caf ; cerror_nocancel
0x1081980b4 <+20>: retq
0x1081980b5 <+21>: nop
0x1081980b6 <+22>: nop
0x1081980b7 <+23>: nop
I exactly followed the tutorial. This is my code.
import UIKit
class ViewController: UIViewController, UITextFieldDelegate , UIImagePickerControllerDelegate, UINavigationControllerDelegate{
@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var mealNameLabel: UILabel!
@IBOutlet weak var photoImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
nameTextField.delegate = self;
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func setDefaultLabelText(_ sender: UIButton) {
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
func textFieldDidEndEditing(_ textField: UITextField) {
mealNameLabel.text = textField.text;
}
@IBAction func selectImageFromPhotoLibrary(_ sender: UITapGestureRecognizer) {
nameTextField.resignFirstResponder()
let imagePickerController = UIImagePickerController()
imagePickerController.sourceType = .photoLibrary
imagePickerController.delegate = self
present(imagePickerController, animated: true, completion: nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
dismiss(animated: true, completion: nil)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
photoImageView.contentMode = .scaleAspectFit
photoImageView.image = pickedImage
}
dismiss(animated: true, completion: nil)
}
}
The error is thrown when I click on the image view to open the image picker. Why is that error thrown?