NSAssert

Terminating app due to uncaught exception `'NSInternalInconsistencyException'`

Posted by kunnan on June 14, 2018

NSAssert

 NSAssert(self.data != nil, @"Argument must be non-nil");
#define NSAssert(condition, desc, ...)	\
    do {				\
	__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS \
	if (!(condition)) {		\
            NSString *__assert_file__ = [NSString stringWithUTF8String:__FILE__]; \
            __assert_file__ = __assert_file__ ? __assert_file__ : @"<Unknown File>"; \
	    [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd \
		object:self file:__assert_file__ \
	    	lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; \
	}				\
        __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS \
    } while(0)
#endif       

See Also

/Users/devzkn/bin/knpost NSAssert Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil' -t objc
#原来""的参数,需要自己加上""

转载请注明: > NSAssert