Home Ask Login Register

Developers Planet

Your answer is one click away!

ExceptionHandler February 2016

Error : unrecognized selector sent to class

I am a complete noob when it comes to Objective C (or even for OOP for that matter). Here is what I am trying to do


@implementation AInterface

 - (BOOL)getParam:(NSData **)a param1:(NSData**)param1 param2:(NSData**)param2

       //Do a bunch of things
       return bool;



@interface AInterface : NSObject

- (BOOL)getParam:(NSData **)a param1:(NSData**)param1 param2:(NSData**)param2;

+ (instancetype) inst;


int main()
    Bool result = NO;
    NSData *a = Nil;
    NSData *b = Nil;
    NSData *c = Nil;

    result = [[AInterface inst] getParam:(NSData **)&a param1:(NSData**)&a param2:(NSData**)&b];

    return result 

When I run this though, I get an error saying failed:

 caught "NSInvalidArgumentException", "+[AInterface inst]: unrecognized selector sent to class 


Vladimir February 2016

Although you declared +inst method in @interface section your class does not have it implemented and that leads to runtime error. You need to add implementation to make it work, e.g.

@implementation AInterface
+ (instancetype)inst {
   return [self new];

Jacob Gorban February 2016

Your problem is that you don't have implementation of +inst in AInterface.m. In your case inst would be something like: [[AInterface alloc] init] but I'd just use [[AInterface alloc] init] instead of calling inst in the first place. Or [AInterface new], which stands for the same.

In general, the rest of your code is not idiomatic Objective-C.

Post Status

Asked in February 2016
Viewed 2,498 times
Voted 13
Answered 2 times


Leave an answer

Quote of the day: live life