对于用户来说,我的应用会间歇性崩溃,但不幸的是,我无法在我的任何设备上重现该问题。报错是:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSConcreteAttributedString initWithString:: nil value'
日志跟踪不清楚崩溃源。 我附上了日志跟踪。 我正在寻找任何可以帮助我追踪这一点的指示。
最佳答案
崩溃的原因在你的标题中...
原因:'NSConcreteAttributedString initWithString::零值'
看起来您正在尝试从字符串创建属性字符串,但该字符串为 nil。
在你执行 NSAttributeString initWithString 之前添加一个守卫以确保字符串不为零,即
if (string) {
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithAttributedString:string];
//other code etc...
}
关于ios - 如何解决 NSInvalidArgumentException 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35316883/