title: Pass core data from selected table cell to new view controller
body: <p>I'm trying to pass data (title, ingredients, steps, image) from the selected table cell to a new view controller. But I don't know how to do that. I got lots of errors, so now I'm starting again. Can anyone help me? I'm new to coding. Thanks:-) My code: </p>
  
  <p><strong>VIEWCONTROLLER.SWIFT</strong></p>
  
  <pre><code>class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
  
      @IBOutlet weak var tableView: UITableView!
      var recipes = [Recipe]()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          tableView.delegate = self
          tableView.dataSource = self
      }
  
      override func viewDidAppear(animated: Bool) {
          fetchAndSetResults()
          tableView.reloadData()
      }
  
      func fetchAndSetResults(){
          let app = UIApplication.sharedApplication().delegate as! AppDelegate
          let context = app.managedObjectContext
          let fetchRequest = NSFetchRequest(entityName: "Recipe")
  
          do {
              let results = try context.executeFetchRequest(fetchRequest)
              self.recipes = results as! [Recipe]
          } catch let err as NSError {
              print(err.debugDescription)
          }
      }
  
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          if let cell = tableView.dequeueReusableCellWithIdentifier("RecipeCell") as? RecipeCell {
              let recipe = recipes[indexPath.row]
              cell.configureCell(recipe)
              return cell
          } else {
              return RecipeCell()
          }
      }
  
      func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
          return 1
      }
  
      func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return recipes.count
      }
  
      func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
          self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
      }
  
      override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
          if (segue.identifier == "RecipeDetail") {
              //I WANT TO PASS THE DATA FROM THE TABLE CELL TO THE NEW VIEW CONTROLLER (RECIPEDETAILVC)
          }
      }
  
      func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -&gt; Bool {
          return true
      }
  
      func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
          if (editingStyle == UITableViewCellEditingStyle.Delete) {
  
              let app = UIApplication.sharedApplication().delegate as! AppDelegate
              let context = app.managedObjectContext
  
              context.deleteObject(recipes[indexPath.row])
              app.saveContext()
  
              recipes.removeAtIndex(indexPath.row)
              tableView.reloadData()
          }
      }
  }
  </code></pre>
  
  <p><strong>CREATERECIPE.SWIFT</strong></p>
  
  <pre><code>class CreateRecipeVC: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
  
      @IBOutlet weak var recipeTitle: UITextField!
      @IBOutlet weak var recipeIngredients: UITextField!
      @IBOutlet weak var recipeSteps: UITextField!
      @IBOutlet weak var recipeImage: UIImageView!
      @IBOutlet weak var addRecipeBtn: UIButton!
  
      var imagePicker: UIImagePickerController!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          imagePicker = UIImagePickerController()
          imagePicker.delegate = self
          recipeImage.layer.cornerRadius = 5.0
          recipeImage.clipsToBounds = true
  
      }
  
      func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
  
          imagePicker.dismissViewControllerAnimated(true, completion: nil)
          recipeImage.image = image
  
      }
  
      @IBAction func addImage(sender: AnyObject!) {
          presentViewController(imagePicker, animated: true, completion: nil)
      }
  
      @IBAction func createRecipe(sender: AnyObject!) {
          if let title = recipeTitle.text where title != "" {
              let app = UIApplication.sharedApplication().delegate as! AppDelegate
              let context = app.managedObjectContext
              let entity = NSEntityDescription.entityForName("Recipe", inManagedObjectContext: context)!
              let recipe = Recipe(entity: entity, insertIntoManagedObjectContext: context)
              recipe.title = title
              recipe.ingredients = recipeIngredients.text
              recipe.steps = recipeSteps.text
              recipe.setRecipeImage(recipeImage.image!)
  
              context.insertObject(recipe)
  
              do {
                  try context.save()
              } catch {
                  print("Could not save recipe")
              }
  
              self.navigationController?.popViewControllerAnimated(true)
          }
      }
  
  }
  </code></pre>
  
  <p><strong>RECIPEDETAILVC.SWIFT</strong></p>
  
  <pre><code>import UIKit
  import CoreData
  
  class RecipeDetailVC: UIViewController {
  
      @IBOutlet weak var recipeImage: UIImageView!
      @IBOutlet weak var recipeTitle: UILabel!
      @IBOutlet weak var recipeIngredients: UILabel!
      @IBOutlet weak var recipeSteps: UILabel!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          //I WANT TO DISPLAY THE CORE DATA INFORMATION FROM THE TABLE CELL I SELECTED.
      }
  }
  </code></pre>
  
  <p><strong>RECIPECELL.SWIFT</strong></p>
  
  <pre><code>class RecipeCell: UITableViewCell {
  
      @IBOutlet weak var recipeTitle: UILabel!
      @IBOutlet weak var recipeImage: UIImageView!
  
      func configureCell(recipe: Recipe) {
          recipeTitle.text = recipe.title
          recipeImage.image = recipe.getRecipeImage()
      }
  
  }
  </code></pre>