Bright Future Bright Future - 1 year ago 78
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

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download