Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not create NSError: unrecognized selector
    text
    copied!<p>I am trying to create a NSError category to make pre-defined errors based upon status codes. However, any time that I try to create a NSError from my category, I get a </p> <pre><code>+[NSError errorWithDomain:code:userInfo:]: unrecognized selector sent to class 0x2b2b20 </code></pre> <p>I have also tried calling the instance version of the NSError Initializer but this has the same result. </p> <pre><code>+(NSError*)errorOfType:(ErrorType)errorType inClassNamed:(NSString*)_nsClassName andMessage:(NSString*)_nsMessage { return [[[self class] alloc]initWithType:errorType inClassNamed: _nsClassName andMessage:_nsMessage]; } #pragma mark - #pragma mark - Init -(id)initWithType:(ErrorType)errorType inClassNamed:(NSString*)_nsClassName andMessage:(NSString*)_nsMessage { NSInteger _nCode = [self codeFromErrorType:errorType]; NSDictionary *_nsUserInfo = [self localizedDescriptionForErrorType:errorType andMessage:_nsMessage]; NSLog(@"Why Does this fail? Is this Nil? %@, \n%i, \n%@", _nsClassName, _nCode, _nsUserInfo); if ([self respondsToSelector:@selector(initWithDomain:code:userInfo:)]) { if (self = [self initWithDomain:_nsClassName code:_nCode userInfo:_nsUserInfo]){ } }else{ NSLog(@"NSERROR Did not create!!!"); } return self; } </code></pre> <p>When I run this code calling the static method, The output is:</p> <pre><code>2013-05-10 17:46:18.851 BMPassSDK-DemoApp[99692:c07] Why Does this fail? Is this Nil? Domain, 107, { NSLocalizedDescription = "A connection to the server could not be made. Please Try again later. "; } 2013-05-10 17:46:18.851 BMPassSDK-DemoApp[99692:c07] NSERROR Did not create!!! 2013-05-10 17:46:18.852 BMPassSDK-DemoApp[99692:c07] +[NSError errorWithDomain:code:userInfo:]: unrecognized selector sent to class 0x2b2b20 (lldb) po 0x2b2b20 $0 = 2829088 NSError (lldb) </code></pre> <p>Anyone have any suggestions on what I am missing?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload