This error can be caused nesting errors in the code preceding the line. It may have nothing to do with the line itself. Check and/or post the code above the line where the error occurs.
If the error message you posted is the actual message you got back, then you have a simple typo of writing NSRangeExpected for NSRangeException.
Update:
Okay, looking over it again, the answer is simple and I just missed it. NSException
is a class but NSRangeException
is a name defined in a string constant:
extern NSString *NSRangeException;
... which simply returns a string of "NSRangeException".
Obviously, the @catch
is expecting to receive a NSException
object but gets a NSString object instead.
You can setup a @catch
to accept a string like this:
@catch(NSString *stringException){...
or
@catch(id idException){...
... but usually there is no reason to.
You use NSRangeException and the other exception names to test against the name
of the NSException
instance that the @catch
catches.