I have a requirement to check whether a String contains a particular string or not.For that purpose i am using a function of NSString class called ccontainsstring. This function works fine in ios8 without throwing any kind of exception but in case of ios7 it is throwing an exception called
unrecognized selector sent to instance
I have used try & catch block to prevent the exception but may i know why this is happening?
Thanks in advance
Once you run this line of code you will instantly get an error message in the console area, which look s like this (unrecognized selector sent to instance). Since the selector is another name for the method, the error is basically saying that it doesn't recognize the function that you're trying to call on this object.
You can check in framework header.
- (BOOL)containsString:(NSString *)aString NS_AVAILABLE(10_10, 8_0);
This method of containsString only exist after iOS 8 so its obvious that it will throw error in iOS7....
Please use below method for ios7 and you can use above method for ios8:
if ([string rangeOfString:@"bla"].location != NSNotFound)
{
NSLog(@"charecter found");
}
May be this can solve your issue. Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With