title: Unable to take a photo and have it persist in core data
body: <p>Can someone please help with an <code>UIImagePickerController</code> function and a way to save? I have been able to take a photo and even have it show up in my <code>UIImageView</code>, but have yet to be able to keep it there, where as the text I'm working with has been saved.  </p>
  
  <pre><code>import UIKit
  import CoreData
  
  class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
  
      var newKid: Kid? = nil
      var pickerController = UIImagePickerController()
  
      // MARK: - IBOutlet
  
      @IBOutlet weak var nameText: UITextField!
      @IBOutlet weak var ageText: UITextField!
      @IBOutlet weak var imageView: UIImageView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          if newKid != nil {
              nameText.text = newKid?.name
              ageText.text = newKid?.age
           // imageView.image = newKid?.image
          } 
      }
  
      // MARK: - IBAction
  
      @IBAction func cancelTapped(sender: AnyObject) {
          dismissVC()
      }
  
      @IBAction func saveTapped(sender: AnyObject) {
          if newKid != nil {
              editEntry()
          } else {
              newEntry()
          }
          dismissVC()
      }
  
      @IBAction func takePhoto(sender: AnyObject) {
          pickerController.delegate = self
          pickerController.sourceType = .Camera
          self.presentViewController(pickerController, animated: true, completion: nil)
      }
  
      // MARK: - Helper Functions
  
      func newEntry() {
  
          var context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
  
          let entity = NSEntityDescription.entityForName("Kid", inManagedObjectContext: context!)
  
          let newKid = Kid(entity: entity!, insertIntoManagedObjectContext: context)
  
          newKid.name = nameText.text
          newKid.age = ageText.text
       // newKid.image = imageView.image
       // context?.save(nil)
          saveEntry()
          println(newKid)
          println("Object saved.")
          dismissVC()
      }
  
      func editEntry() {
          newKid?.name = nameText.text
          newKid?.age = ageText.text
          newKid?.image = imageView.image
      }
  
      func saveEntry() {
          var context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
          context?.save(nil)
      }
  
      func dismissVC() {
          navigationController?.popToRootViewControllerAnimated(true)
      }
  
      func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
          let mediaType = info[UIImagePickerControllerMediaType] as! String
          self.dismissViewControllerAnimated(true, completion: nil)
          let image = info[UIImagePickerControllerOriginalImage] as! UIImage
          imageView.image = image
      }
  
      @IBAction func useCamera(sender: AnyObject) {
          if UIImagePickerController.isSourceTypeAvailable(
              UIImagePickerControllerSourceType.Camera) {
  
                  let imagePicker = UIImagePickerController()
  
                  imagePicker.delegate = self
                  imagePicker.sourceType = .Camera
                  imagePicker.allowsEditing = false
  
                  self.presentViewController(imagePicker, animated: true,
                      completion: nil)
          }
      }
  }
  </code></pre>