ios – 应用程序由于NSInvalidArgumentException而崩溃但无法找到它

ios – 应用程序由于NSInvalidArgumentException而崩溃但无法找到它,第1张

概述使用以下调试运行它时我的应用程序崩溃: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSConcreteMutableAttributedString initWithString:attributes:: nil value'*** First throw call s 使用以下调试运行它时我的应用程序崩溃:

*** Terminating app due to uncaught exception 'NSinvalidargumentexception',reason: 'NSConcreteMutableAttributedString initWithString:attributes:: nil value'*** First throw call stack:(    0   CoreFoundation                      0x0000000102a83495 __exceptionPreprocess + 165    1   libobjc.A.dylib                     0x00000001027e299e objc_exception_throw + 43    2   CoreFoundation                      0x0000000102a832ad +[NSException raise:format:] + 205    3   Foundation                          0x00000001023d993e -[NSConcreteMutableAttributedString initWithString:attributes:] + 129    4   myApp                             0x0000000100006da5 -[WelcomeVIEwController vIEwDIDLoad] + 373    5   UIKit                               0x000000010148559e -[UIVIEwController loadVIEwIfrequired] + 562    6   UIKit                               0x0000000101485777 -[UIVIEwController vIEw] + 29    7   UIKit                               0x00000001017902e2 -[UIClIEntRotationContext initWithClIEnt:toOrIEntation:duration:anDWindow:] + 390    8   UIKit                               0x00000001013cbffa -[UIWindow _setRotatableClIEnt:toOrIEntation:updateStatusbar:duration:force:isRotating:] + 1109    9   UIKit                               0x00000001013cbb9f -[UIWindow _setRotatableClIEnt:toOrIEntation:updateStatusbar:duration:force:] + 36    10  UIKit                               0x00000001013cbaef -[UIWindow _setRotatableVIEwOrIEntation:updateStatusbar:duration:force:] + 101    11  UIKit                               0x00000001013cadfe -[UIWindow _updatetoInterfaceOrIEntation:duration:force:] + 377    12  UIKit                               0x000000010148970a -[UIVIEwController _tryBecomeRootVIEwControllerInWindow:] + 147    13  UIKit                               0x00000001013c5b1b -[UIWindow addRootVIEwControllerVIEwIfPossible] + 490    14  UIKit                               0x00000001013c5c70 -[UIWindow _setHIDden:forced:] + 282    15  UIKit                               0x00000001013ceffa -[UIWindow makeKeyAndVisible] + 51    16  UIKit                               0x000000010138ac98 -[UIApplication _callinitializationDelegatesForURL:payload:suspended:] + 1788    17  UIKit                               0x000000010138ea0c -[UIApplication _runWithURL:payload:launchOrIEntation:statusbarStyle:statusbarHIDden:] + 660    18  UIKit                               0x000000010139fd4c -[UIApplication handleEvent:withNewEvent:] + 3189    19  UIKit                               0x00000001013a0216 -[UIApplication sendEvent:] + 79    20  UIKit                               0x0000000101390086 _UIApplicationHandleEvent + 578    21  GraphiCSServices                    0x00000001047dd71a _PurpleEventCallback + 762    22  GraphiCSServices                    0x00000001047dd1e1 PurpleEventCallback + 35    23  CoreFoundation                      0x0000000102a05679 __CFRUNLOOP_IS_CALliNG_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41    24  CoreFoundation                      0x0000000102a0544e __CFRunLoopDoSource1 + 478    25  CoreFoundation                      0x0000000102a2e903 __CFRunLoopRun + 1939    26  CoreFoundation                      0x0000000102a2dd83 CFRunLoopRunspecific + 467    27  UIKit                               0x000000010138e2e1 -[UIApplication _run] + 609    28  UIKit                               0x000000010138fe33 UIApplicationMain + 1010    29  myApp                             0x0000000100006b03 main + 115    30  libdyld.dylib                       0x00000001033c25fd start + 1)libc++abi.dylib: terminating with uncaught exception of type NSException

问题是我知道一个事实我从来没有使用过NSConcreteMutableAttributedString我已经检查并仔细检查了我的代码,看看我是否遗漏了一些东西但是我一直空白,有什么想法可以做些什么来解决这个问题?

更新

我添加了一个异常断点,告诉我以下行导致我的应用程序崩溃:

NSMutableAttributedString *thirdGreetingAttr = [[NSMutableAttributedString alloc] initWithString:thirdGreeting attributes:secondGreetingAttrs19];    self.welcomeUserLabel.attributedText = thirdGreetingAttr;

“好吧,很奇怪”我想,2周前,当我上次触摸这个项目时,这工作得很好,这是完整的代码块:

NSDictionary *secondGreetingAttrs19 = [NSDictionary dictionaryWithObjectsAndKeys:fitnestFontBold,NSFontAttributename,nil];    Nsstring *thirdGreeting = currentUser.username;    NSMutableAttributedString *thirdGreetingAttr = [[NSMutableAttributedString alloc] initWithString:thirdGreeting attributes:secondGreetingAttrs19];    self.welcomeUserLabel.attributedText = thirdGreetingAttr;

所以我继续评论导致问题的2行,并且app运行得很好.我取消评论线条回到最初的原因,并且令我惊讶的是构建运行JUST FINE:/ what ???谁知道这里发生了什么?

UPDATE

正如所选择的答案所说,我意识到发生了这个错误,因为我的用户名属性返回了一个空值.

解决方法 确保你的thirdGreeting(Nsstring * thirdGreeting = currentUser.username;)不是nil值.
我认为thireGreeting是零,你应该改为

Nsstring *thirdGreeting = (currentUser.username.length>0) ? currentUser.username.length : @"";
总结

以上是内存溢出为你收集整理的ios – 应用程序由于NSInvalidArgumentException而崩溃但无法找到它全部内容,希望文章能够帮你解决ios – 应用程序由于NSInvalidArgumentException而崩溃但无法找到它所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1072413.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存