Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

I need help with correcting my code, the code succeeds when building the app but then comes back with an error ??

The build of the app succeeds and says there are no issues but then when running it, it comes back to say an error of "Thread 1: signal SIGABRT" ?? apparently (as told before) this is to do with something in my code not being connected but I can't figure it out. Here is my code:

import UIKit

class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate { let imagePicker = UIImagePickerController() @IBOutlet weak var imageViewer: UIImageView!

override func viewDidAppear(_ animated: Bool) {

    if UIImagePickerController.isCameraDeviceAvailable( UIImagePickerControllerCameraDevice.front) {
        imagePicker.delegate = self
        imagePicker.sourceType = UIImagePickerControllerSourceType.camera
        present(imagePicker, animated: true, completion: nil)
    }
}


override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
    dismiss(animated: true, completion: nil)
    imageViewer.image = image
}

}

1 Answer

Hi Alfie,

I had this problem a couple of hours ago.

The way I fixed it was to check that there was only one connection on the IBOutlet. You can do this by right clicking the view element in your story board.

It worked for me so maybe worth a try.

All the best,

Mitch