-1

I am doing this online swift course and now I am trying to combine two different projects with each other to create my own project. Basically I had a task manager app but now I want to add an image to each task.

I can't get my head around the following:

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
        let image = info[UIImagePickerControllerOriginalImage] as UIImage
        let imageData = UIImageJPEGRepresentation(image, 1.0);
        let managedObjectContext = (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext
        let entityDescription = NSEntityDescription.entityForName("TaskModel", inManagedObjectContext: managedObjectContext!)
        let taskItem = TaskModel(entity: entityDescription!, insertIntoManagedObjectContext: managedObjectContext!)
        taskItem.image = imageData;
        (UIApplication.sharedApplication().delegate as AppDelegate).saveContext()
        self.dismissViewControllerAnimated(true, completion: nil)

    }

When I run my app I get the following error:

2015-06-10 20:43:59.726 TaskIt[85735:13802555] -[TaskModel setImage:]: unrecognized selector sent to instance 0x792a4800

I figured out that when I comment out taskItem.image = imagaData; the code works. But I cant figure out what's wrong.

Anyone that can help me?

Plaksel
  • 160
  • 3
  • 13
  • http://stackoverflow.com/questions/25853947/how-can-i-debug-unrecognized-selector-sent-to-instance-error -- It's written for Objective-C but the same principles apply. – Hot Licks Jun 10 '15 at 20:01

1 Answers1

0

Looks like the TaskModel class does not have an image property, and so you can't call setImage: on an object of this class (which is what taskItem.image = actually does.)

Luke
  • 7,110
  • 6
  • 45
  • 74
  • Thanks! Im mister stupid here, selected the wrong model version for my db that did not include image – Plaksel Jun 10 '15 at 20:07