Objective-C iOS应用程序在CFStringAppend期间因未知原因崩溃

时间:2017-10-26 15:59:17

标签: ios iphone crash

在我的iPhone应用程序中,对于某些用户,只要他们打开某个窗口,该应用就会崩溃。同样的窗口对我和其他人来说很好,但总会导致某些人崩溃。目前尚不清楚它失败的人与其工作正常的人之间的区别是什么。

打开特定视图的动画将正常运行,但在动画结束后会立即导致崩溃。

他们向我发送了崩溃日志,但很难理解究竟出了什么问题。我希望你能帮助我理解。崩溃日志给出的失败原因是以下异常:

Last Exception Backtrace:
0   CoreFoundation                  0x1836ffd38 __exceptionPreprocess + 124
1   libobjc.A.dylib                 0x182c14528 objc_exception_throw + 55
2   CoreFoundation                  0x18370d1f8 -[NSObject+ 1372664 (NSObject) doesNotRecognizeSelector:] + 139
3   UIKit                           0x18cec7cc4 -[UIResponder doesNotRecognizeSelector:] + 295
4   CoreFoundation                  0x1837056e4 ___forwarding___ + 1379
5   CoreFoundation                  0x1835eb0dc _CF_forwarding_prep_0 + 91
6   CoreFoundation                  0x1835d6be8 CFStringAppend + 519
7   CoreFoundation                  0x1836bddf0 __CFStringAppendFormatCore + 9271
8   CoreFoundation                  0x1836bf658 _CFStringCreateWithFormatAndArgumentsAux2 + 131
9   AccessibilityUtilities          0x192d6b388 _AXStringForArgs + 279
10  UIKit                           0x1a242adf8 -[UIViewControllerAccessibility viewDidAppear:] + 267
11  UIKit                           0x18cb2869c -[UIViewController _setViewAppearState:isAnimating:] + 851
12  UIKit                           0x18cb28c08 -[UIViewController _endAppearanceTransition:] + 227
13  UIKit                           0x18cbcee00 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1327
14  UIKit                           0x1a2440cd4 -[UINavigationControllerAccessibility navigationTransitionView:didEndTransition:fromView:toView:] + 111
15  UIKit                           0x18cc96bbc __49-[UINavigationController _startCustomTransition:]_block_invoke + 251
16  UIKit                           0x18cc229d8 -[_UIViewControllerTransitionContext completeTransition:] + 115
17  UIKit                           0x18cd67d30 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.124 + 751
18  UIKit                           0x18cb47d7c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 763
19  UIKit                           0x18cb4770c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 311
20  UIKit                           0x18cb47418 -[UIViewAnimationState animationDidStop:finished:] + 295
21  UIKit                           0x1a2468970 -[UIViewAnimationStateAccessibility animationDidStop:finished:] + 131
22  QuartzCore                      0x1876ebd6c CA::Layer::run_animation_callbacks+ 1232236 (void*) + 283
23  libdispatch.dylib               0x183085048 _dispatch_client_callout + 15
24  libdispatch.dylib               0x183091b74 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1015
25  CoreFoundation                  0x1836a7f20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
26  CoreFoundation                  0x1836a5afc __CFRunLoopRun + 2011
27  CoreFoundation                  0x1835c62d8 CFRunLoopRunSpecific + 435
28  GraphicsServices                0x185457f84 GSEventRunModal + 99
29  UIKit                           0x18cb73880 UIApplicationMain + 207
30  Flyskyhy                        0x10490bd80 main + 32128 (main.m:17)
31  libdyld.dylib                   0x1830ea56c start + 3

崩溃日志似乎表明它在执行CFStringAppend时出错,但不清楚哪个字符串是问题,或者它有什么问题,甚至是为什么需要CFStringAppend 。在动画开始之前,视图中可见的所有字符串都已填充,并且它们都是正确的。

编辑:

根据要求,这是启动视图的代码。一切都在NavigationController下,所以新的视图控制器被推到导航堆栈上打开它。

WaypointEditController *controller = [[WaypointEditController alloc] initWithNibName:@"WayPointEdit" bundle:nil];
controller.navigationItem.title = @"New Waypoint";
// initialisation of other, custom, fields of controller

[self.navigationController pushViewController:controller animated:YES];

推送的WaypointEditController类派生自UIViewController。覆盖viewWillAppear,以初始化视图的字段。但是 - 相关的是 - viewDidAppear 被覆盖。

如果相关,以下是viewWillAppear方法中最重要的操作:

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];

    self.navigationItem.title = @"New Waypoint";

    // other initialisation of internal fields
}

1 个答案:

答案 0 :(得分:2)

和你一样,我有客户报告这个问题,我可以看到XCode从生产中下载的堆栈跟踪,但我无法重现它...直到我尝试启用“配音”。

我尝试过的其他辅助功能选项正常。

堆栈跟踪显示iOS正在向UILabel的实例发送“length”选择器。这看起来很奇怪。为了看看会发生什么,我向UILabel添加了一个“长度”方法来返回UILabel文本属性的长度。然后它失败了_encodingCantBeStoredInEightBitCFString的未知选择器。很明显,iOS认为我的UILabel不是它。

这最终是因为“描述”用于我的UILabel属性/ IBOutlet的名称。

为了解决这个问题,我将属性从“description”重命名为不同的东西。我怀疑我的合成“描述”getter覆盖了NSObject的描述方法(返回一个NSString,它适合发送到我的UILabel的选择器)。

相关问题