我一直在努力應對一場不應該發生的非常奇怪的崩潰。我通過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