NSInvalidArgumentException


#1

I’m having a problem with this chapter. When running it at the end of the chapter, I keep getting an error that says:

Does anyone know how to fix this issue? I’ve done some searching, and I can’t seem to figure out a solution.


#2

This means you are trying to add a nil key to the BNRImageStore… which means you aren’t generating the imageKey correctly. Paste the code around the place where you generate the imageKey for the BNRItem.


#3

Was able to fix it! Thanks a lot!


#4

How did you fix this?


#5

I see the following exception:
Homepwner[586:f803] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘+[BNRImageStore _isResizable]: unrecognized selector sent to class 0x7fa0’

This is thrown at the following line of code in DetailViewController.m

  • (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {

    .
    .
    .

       [self dismissViewControllerAnimated:YES completion:nil];
    

}

How do I fix this?


#6

Somewhere within the code you have dotted out, you are using BNRImageStore in a place where you should be using a UIImage. You’d have to paste that code for me to see where.


#7

I had the same _isResizeable error:
I let code completion put ‘item’ here

[[BNRImageStore sharedStore] setImage:item forKey:key];

when it obviously should have been ‘image’


#8

I appreciate this reply comes some time after the thread was originally started, however this may benefit others in the future.

If you are getting this error after trying the Bronze challenge, it is more than likely caused by where you place the statement:

I had placed this inside the IF statement where your set the source type, and because I was running the project on my device the error was not occurring. However, when I got to Chapter 13 and ran the project on the iPad simulator, the error occurred.

Basically you want to place the above statement after you create the pointer the the imagePicker (outside of the IF statement).

Nick
http://myfirstiphoneapp.co.uk