ios NSString crash

Recently encountered an exception, and solved a bit.

exception description:

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFString rangeOfString:options:range:locale:]: nil argument' terminating with uncaught exception of type NSException abort() called

First we look at the wrong reason, and then the corresponding code to find where it will go wrong, view the description of the method.
Solution:
NSString method "containsString:"
Declaration
-(BOOL)containsString:(NSString *)str;
Parameters
str -> The string to search for. This value must not be nil.
Return Value -> YES if the receiver contains str, otherwise NO.

posted @ 2017-08-24 08:58  笑笑就好90  阅读(496)  评论(0编辑  收藏  举报