-[Possession serialNumber]: unrecognized selector sent to in


I am working through lesson 2 and i keep getting this error. I have read and re-read and re-typed in everything as the book has said but i can’t seem to get past page 48.

Instead of seeing the values for possessionName, serialNumber, and valueInDollars, I am getting this error:

2011-11-15 20:46:17.601 RandomPossessions[2736:407] -[Possession serialNumber]: unrecognized selector sent to instance 0x1005001e0
2011-11-15 20:46:17.609 RandomPossessions[2736:407] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[Possession serialNumber]: unrecognized selector sent to instance 0x1005001e0’

Followed by a "*** First throw call stack: " and a list of things.

Can someone please help? I’ve been pulling my hair out for 2 hours trying to figure out what mistake i made. :smiling_imp:


The Possession lesson has two stages, first where you write the accessor methods, second where you learn that ‘property’ and ‘synthesize’ can do this for you.

I don’t know in which stage you are currently. However, “unrecognized selector” means that the serialNumber method is not implemented.
So check again if you have everything in place as necessary:

  1. Possession.h: Declaration of serialNumber in the @interface Possession block
  2. Possession.h: @property declaration for serialNumber
  3. Possession.m: serialNumber in @synthesize, or explicit implementation of accessor methods such as serialNumber
    where (1) is optional because the @property declaration creates an associated member variable if it does not exist

Hope this helps.


I am pretty sure i am not at the part where i am doing the @property.

Within possession.h i create the instance variable by saying (in addition to the other variables)
NSString *serialNumber;

Then below that (along with the others) i have
-(void)setSerialNumber:(NSString *)str;
-(NSString *)serialNumber;

In possession.m i have
serialNumber = str;
-(NSString *)SerialNumber
return serialNumber;

And then finally within main.m (maybe this is where the problem is) i import that header file with
#import “Possession.h”

Then below, beneath the NSArray exercise we did earlier in the chapter I have

Possession *p = [[Possession alloc] init];

NSLog(@"%@ %@ %@ %d",[p possessionName], [p dateCreated],
[p serialNumber], [p valueInDollars]);

I think i understand what the code is supposed to be doing, but I don’t understand why its not doing that. The book keeps telling me to build/run and i should receive no errors. My build is successful but when i check the log, the output is not what the book is telling me i should get back.

Thank you in advance for your help!!


[quote=“lastresort”]In possession.m i have

-(NSString *)SerialNumber
return serialNumber;

THERE is your typo! The method name should be ‘serialNumber’, not ‘SerialNumber’.


GAH i knew it was going to be something THAT simple! Thank you SO MUCH for your eyes!!! :blush: Everything is working perfect now.

I will probably be back, thank you so much for the swift responses too!