     appDelegate.memes.append(meme)
   }
   
+  // Generates an image (memedImage) that is the original image with the text fields on top of it
   func generateMemedImage() -> UIImage {
     // Hide top and bottom toolbars
     topToolbar.hidden = true

    dismissViewControllerAnimated(true, completion: nil)
  }

  func imagePickerControllerDidCancel(picker: UIImagePickerController) {
    dismissViewControllerAnimated(true, completion: nil)
  }
  
  func save() {
    var meme = Meme(topText: topTextField.text, bottomText: bottomTextField.text, originalImage: imagePickerView.image!, memedImage: generateMemedImage())
    

    activityVC.completionWithItemsHandler = {
      (activity, success, items, error) in
      if (success) {
        self.save() // The meme is saved only if the activity view operation was succesful
      }
      self.dismissViewControllerAnimated(true, completion: nil)
    }
  }
  
  // Dismiss the view if the user cancel the edition
  @IBAction func cancelEdition(sender: AnyObject) {
    dismissViewControllerAnimated(true, completion: nil)
  }

  // UIImagePickerControllerDelegate methods
  
  // Sets the imagePickerView image, enables the shareButton and dismiss the view after media was picked
  func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
    if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
      imagePickerView.image = image
