Compare NSError object against the error code

138 Views Asked by At

I have a ObjC method that is setup like this:

- (void) doSomethingWithReply:(void(^)(NSError *))reply

I'm calling this method from another class where I have it setup like this:

[someObject doSomethingWithReply:^(NSError *error)
                                         {
                                            localerr = error;
                                         }];

Ideally I would like to act on based on the return code I receive from my method. For instance, the method doSomethingWithReply could return EACCES or EBUSY. Depending on the return code received, I would like to do something in my calling method. What is the best way to compare localerr against EBUSY or EACCESS?

Using a simple comparison seems to throw an error.

Edit:

Comparison methods I tried:

if(localerr == EBUSY)
{
    //do something
}

//Throws the following warning:
//Comparison between pointer and integer ('NSError *' and 'int')

if(*localerr == EBUSY)
{
    //do something
}
//This throws the follow error:
//Invalid operands to binary expression ('NSError' and 'int')
0

There are 0 best solutions below