Search code examples
iosobjective-cunrecognized-selector

Why do I get the error "Unrecognized selector sent to instance error"


I'm just learning Objective C and have come across this issue. I have created a simple manager class like so

#import <Foundation/Foundation.h>

@interface PassManager : NSObject

- (void)isValidCredentials:(NSString *) username
          withPassword:(NSString *) password
              wasValid:(void(^)(BOOL success))handler;

@end

the implementation is as follows

#import "PassManager.h"

@implementation PassManager

- (void)isValidCredentials:(NSString *) username
          withPassword:(NSString *) password
              wasValid:(void(^)(BOOL success))handler
{
    handler(true); 
}

@end

This builds but upon running I get the error:

"2016-01-27 16:40:41.555 MessyApp[19395:897750] -[PassManager initWithConfiguration:]: unrecognized selector sent to instance 0x7fd12a413d30 2016-01-27 16:40:41.560 MessyApp[19395:897750] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PassManager initWithConfiguration:]: unrecognized selector sent to instance 0x7fd12a413d30'".

What am I doing wrong?


Solution

  • After speaking to originaluser2 he showed me it was something else causing the problem. I was using a library called Parse that required startup code in the appdelegate class and it was that what was blowing up. Once he showed me that I looked at what else I did and realised I had created a class called ParseManager that was causing some sort of name conflict. I changed this classes name and sure enough it all started working. Bad question on my part I'm afraid but Im a new to this platform