我一直在努力应对一场不应该发生的非常奇怪的崩溃。我通过Hockeyapp收到崩溃报告,它不断报告崩溃,应用程序不应该崩溃。我已经面对这个问题已经1周了。崩溃在哪里应该不会在Swift中崩溃(“if,let,where”语句)
这是崩溃报告的代码
0 TeacherBox 0x00000001000864f0 TeacherBox.RequestLessonViewController.loadExistingRequests() ->() (RequestLessonViewController.swift:755)
1 TeacherBox 0x0000000100086514 @objc TeacherBox.RequestLessonViewController.loadExistingRequests() ->() (RequestLessonViewController.swift:0)
2 TeacherBox 0x0000000100086a84 function signature specialization <Arg[0] = Dead> of TeacherBox.RequestLessonViewController.viewDidAppear (Swift.Bool) ->() (RequestLessonViewController.swift:122)
3 TeacherBox 0x000000010007e570 @objc TeacherBox.RequestLessonViewController.viewDidAppear (Swift.Bool) ->() (RequestLessonViewController.swift:0)
4 UIKit 0x00000001895b84dc -[UIViewController _setViewAppearState:isAnimating:] + 844
5 UIKit 0x00000001895b8a40 -[UIViewController _endAppearanceTransition:] + 216
6 UIKit 0x0000000189671038 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1232
7 UIKit 0x0000000189742198 __49-[UINavigationController _startCustomTransition:]_block_invoke + 228
8 UIKit 0x00000001896c7cc4 -[_UIViewControllerTransitionContext completeTransition:] + 112
9 UIKit 0x00000001898181ec __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.97 + 708
10 UIKit 0x00000001895d9214 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 488
11 UIKit 0x00000001895d8d38 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 308
12 UIKit 0x00000001895d8b78 -[UIViewAnimationState animationDidStop:finished:] + 156
线:
if let booking = rescheduleBooking where booking.confirmed! == 0 {
existingRequests.append(booking)
}
线755是if语句。在swift中的“if,let,where”语句中,“let”检查rescheduleBooking是否存在,如果它存在并被赋值,那么where语句会被执行....对吗?...无论如何,我测试过本地在我的设备和模拟器,它不会在那里崩溃,无论变量的值...它发生在一个不同的设备,我手上没有..
请,如果你有任何建议,或者,如果我没有正确理解“如果,让我们放在哪里”条款,我将非常感谢您的帮助和评论。
谢谢..
删除'let'和尝试。 –
这将崩溃,如果'booking.confirmed'为零,因为你有力量解开它 – Paulw11