【发布时间】:2016-09-17 11:10:24
【问题描述】:
我一直在与一个根本不应该发生的非常奇怪的崩溃作斗争。我通过 Hockeyapp 收到崩溃报告,它不断报告应用程序根本不应该崩溃的行中的崩溃。我已经面临这个问题 1 周了。
这是崩溃报告
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 语句......我是对的吗?......无论如何,我测试了在我的设备和模拟器中本地并且它不会在那里崩溃,无论变量的值是什么......它发生在我手头没有的不同设备中......
如果您有任何建议,或者如果我没有正确理解“if, let where”子句,我将非常感谢您的帮助和 cmets。
谢谢..
【问题讨论】:
-
删除
let并尝试。 -
如果
booking.confirmed为 nil 将会崩溃,因为你已经强制解包了