gpt4 book ai didi

ios - 如何解决 NSInvalidArgumentException 错误?

转载 作者:行者123 更新时间:2023-11-29 12:05:08 28 4
gpt4 key购买 nike

对于用户来说,我的应用会间歇性崩溃,但不幸的是,我无法在我的任何设备上重现该问题。报错是:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSConcreteAttributedString initWithString:: nil value'

日志跟踪不清楚崩溃源。我附上了日志跟踪。我正在寻找任何可以帮助我追踪这一点的指示。

screenshot of sample exception

最佳答案

崩溃的原因在你的标题中...

原因:'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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com