我无法重新创建某些来自应用商店的应用用户的崩溃,因此无法解决。
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010008d180
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [3253]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 FGS 0x000000010008d180 LoginViewController.setupUI() + 896 (<compiler-generated>:94)
1 FGS 0x000000010008cde4 @objc LoginViewController.viewDidLoad() + 96 (LoginViewController.swift:87)
2 UIKitCore 0x00000001a0c64364 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104 (UIViewController.m:2252)
3 UIKitCore 0x00000001a0c68f98 -[UIViewController loadViewIfRequired] + 952 (UIViewController.m:3351)
4 UIKitCore 0x00000001a0bd7c88 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 172 (UINavigationController.m:6332)
5 UIKitCore 0x00000001a0bd7f9c -[UINavigationController _startTransition:fromViewController:toViewController:] + 180 (UINavigationController.m:6367)
6 UIKitCore 0x00000001a0bd8db4 -[UINavigationController _startDeferredTransitionIfNeeded:] + 1104 (UINavigationController.m:6579)
7 UIKitCore 0x00000001a0bda0f8 -[UINavigationController __viewWillLayoutSubviews] + 168 (UINavigationController.m:6853)
8 UIKitCore 0x00000001a0bbd4e0 -[UILayoutContainerView layoutSubviews] + 228 (UILayoutContainerView.m:86)
9 UIKitCore 0x00000001a1747abc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2156 (UIView.m:16956)
10 libobjc.A.dylib 0x000000019cf1faf0 -[NSObject performSelector:withObject:] + 68 (NSObject.mm:2182)
11 QuartzCore 0x00000001a3ce60f4 -[CALayer layoutSublayers] + 292 (CALayer.mm:9582)
12 QuartzCore 0x00000001a3ce63fc CA::Layer::layout_if_needed(CA::Transaction*) + 484 (CALayer.mm:9459)
13 QuartzCore 0x00000001a3cf9964 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 140 (CALayer.mm:2434)
14 QuartzCore 0x00000001a3c3ec1c CA::Context::commit_transaction(CA::Transaction*, double) + 308 (CAContextInternal.mm:1991)
15 QuartzCore 0x00000001a3c69bd8 CA::Transaction::commit() + 684 (CATransactionInternal.mm:438)
16 UIKitCore 0x00000001a12b7788 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 84 (UIApplication.m:10823)
17 CoreFoundation 0x000000019d18507c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 (CFRunLoop.c:1774)
18 CoreFoundation 0x000000019d184800 __CFRunLoopDoBlocks + 268 (CFRunLoop.c:1815)
19 CoreFoundation 0x000000019d17f800 __CFRunLoopRun + 1088 (CFRunLoop.c:2884)
20 CoreFoundation 0x000000019d17f098 CFRunLoopRunSpecific + 480 (CFRunLoop.c:3192)
21 GraphicsServices 0x00000001a72e9534 GSEventRunModal + 108 (GSEvent.c:2246)
22 UIKitCore 0x00000001a129f7ac UIApplicationMain + 1940 (UIApplication.m:4753)
23 FGS 0x000000010000da5c main + 68 (PolicyTableViewCell.swift:31)
24 libdyld.dylib 0x000000019cffef30 start + 4
它说它在LoginViewController
setupUI
中崩溃,这是该函数中的代码:
private func setupUI() {
let hour = Calendar.current.component(.hour, from: Date())
var greetingMessage: String = ""
switch hour {
case 5..<12:
greetingMessage = "Good morning"
case 12..<18:
greetingMessage = "Good afternoon"
case 18..<24:
greetingMessage = "Good evening"
case 24..<5:
greetingMessage = "Good night"
default:
break
}
//Using keychain to store user name is case of app deletion, so if reinstalled, will remember him and greet him again.
if let fgsUser = keychain.get(Constants.kFgsUser) {
goodMorningLabel.text =
"""
\(greetingMessage)
\(fgsUser)
"""
}
else {
goodMorningLabel.text = greetingMessage
}
}
对于钥匙串部分,我正在使用KeychainSwift
17.0版
答案 0 :(得分:1)
您需要更改最后一种情况。
您需要将24替换为0。
private func setupUI() {
let hour = Calendar.current.component(.hour, from: Date())
var greetingMessage: String = ""
switch hour {
case 5..<12:
greetingMessage = "Good morning"
case 12..<18:
greetingMessage = "Good afternoon"
case 18..<24:
greetingMessage = "Good evening"
case 0..<5:
greetingMessage = "Good night"
default:
break
}
//Using keychain to store user name is case of app deletion, so if reinstalled, will remember him and greet him again.
if let fgsUser = keychain.get(Constants.kFgsUser) {
goodMorningLabel.text =
"""
\(greetingMessage)
\(fgsUser)
"""
}
else {
goodMorningLabel.text = greetingMessage
}
}