Bright Future Bright Future - 9 months ago 40
iOS Question

Using delegate error: cannot assign value of type

I'm trying to implement this framework from Github:

Then I created an

in my view controller as described in the

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UINavigationBarDelegate {

@IBAction func addMemory(sender: UIBarButtonItem) {

let imagePickerController = ImagePickerController()
imagePickerController.delegate = self //Error here
presentViewController(imagePickerController, animated: true, completion: nil)


Error: Cannot assign value of type 'MemoriesTable' to type


You should be implementing ImagePickerDelegate as well, because delegate is of type ImagePickerDelegate. Change as follow

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UINavigationBarDelegate, ImagePickerDelegate {

Make sure you implement protocol methods.


You need to implement following methods of ImagePickerDelegate

public protocol ImagePickerDelegate: class {

   func wrapperDidPress(imagePicker: ImagePickerController, images: [UIImage])
   func doneButtonDidPress(imagePicker: ImagePickerController, images: [UIImage])
   func cancelButtonDidPress(imagePicker: ImagePickerController)