我在运行iOS 9.2的设备上收到关于我的应用程序崩溃的崩溃报告。它并不是每次都会发生,它并不总是发生在应用程序的同一点。有时当用户刚进入时,其他时间刚刚打开。我可以在报告中看到哪条线存在问题,但我不理解错误。
# OS Version: 9.2.1
# Device: iPhone 6
# RAM Free: 27.6%
# Disk Free: 20.6%
#0. Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x100a71c5c _assertionFailed(StaticString, String, StaticString, UInt, flags : UInt32) -> Never (__hidden#16085_:167)
1 libswiftCore.dylib 0x100a919c0 _hidden#1062_ + 504
2 libswiftCore.dylib 0x100a917c8 swift_errorInMain + 26
3 Matura 0x10010b570 specialized APIAsync.getRealmObjectBasedOnString(type : String) -> Object.Type? (APIAsync.swift)
4 Matura 0x10010cec0 specialized APIAsync.checkUserExists(email : String) -> [AnyObject] (APIAsync.swift)
5 Matura 0x10010dacc specialized APIAsync.login(email : String, password : String, callback : (Bool, String) -> ()) -> () (APIAsync.swift)
6 Matura 0x1000cf444 specialized LoginViewController.login(UIButton) -> () (LoginViewController.swift)
7 Matura 0x1000ce644 @objc LoginViewController.login(UIButton) -> () (LoginViewController.swift)
8 UIKit 0x18852fe50 -[UIApplication sendAction:to:from:forEvent:] + 100
9 UIKit 0x18852fdcc -[UIControl sendAction:to:forEvent:] + 80
10 UIKit 0x188517a88 -[UIControl _sendActionsForEvents:withEvent:] + 416
11 UIKit 0x18852f6e4 -[UIControl touchesEnded:withEvent:] + 572
12 UIKit 0x18852f314 -[UIWindow _sendTouchesForEvent:] + 804
13 UIKit 0x188527e30 -[UIWindow sendEvent:] + 784
14 UIKit 0x1884f84cc -[UIApplication sendEvent:] + 248
15 UIKit 0x1884f6794 _UIApplicationHandleEventQueue + 5528
16 CoreFoundation 0x1837bcefc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
17 CoreFoundation 0x1837bc990 __CFRunLoopDoSources0 + 540
18 CoreFoundation 0x1837ba690 __CFRunLoopRun + 724
19 CoreFoundation 0x1836e9680 CFRunLoopRunSpecific + 384
20 GraphicsServices 0x184bf8088 GSEventRunModal + 180
21 UIKit 0x188560d90 UIApplicationMain + 204
22 Matura 0x1000c5748 main (EngleskiPitanja.swift:15)
23 libdispatch.dylib 0x18328a8b8 (Missing)
--
#0. Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x100a71c5c _assertionFailed(StaticString, String, StaticString, UInt, flags : UInt32) -> Never (__hidden#16085_:167)
1 libswiftCore.dylib 0x100a919c0 _hidden#1062_ + 504
2 libswiftCore.dylib 0x100a917c8 swift_errorInMain + 26
3 Matura 0x10010b570 specialized APIAsync.getRealmObjectBasedOnString(type : String) -> Object.Type? (APIAsync.swift)
4 Matura 0x10010cec0 specialized APIAsync.checkUserExists(email : String) -> [AnyObject] (APIAsync.swift)
5 Matura 0x10010dacc specialized APIAsync.login(email : String, password : String, callback : (Bool, String) -> ()) -> () (APIAsync.swift)
6 Matura 0x1000cf444 specialized LoginViewController.login(UIButton) -> () (LoginViewController.swift)
7 Matura 0x1000ce644 @objc LoginViewController.login(UIButton) -> () (LoginViewController.swift)
8 UIKit 0x18852fe50 -[UIApplication sendAction:to:from:forEvent:] + 100
9 UIKit 0x18852fdcc -[UIControl sendAction:to:forEvent:] + 80
10 UIKit 0x188517a88 -[UIControl _sendActionsForEvents:withEvent:] + 416
11 UIKit 0x18852f6e4 -[UIControl touchesEnded:withEvent:] + 572
12 UIKit 0x18852f314 -[UIWindow _sendTouchesForEvent:] + 804
13 UIKit 0x188527e30 -[UIWindow sendEvent:] + 784
14 UIKit 0x1884f84cc -[UIApplication sendEvent:] + 248
15 UIKit 0x1884f6794 _UIApplicationHandleEventQueue + 5528
16 CoreFoundation 0x1837bcefc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
17 CoreFoundation 0x1837bc990 __CFRunLoopDoSources0 + 540
18 CoreFoundation 0x1837ba690 __CFRunLoopRun + 724
19 CoreFoundation 0x1836e9680 CFRunLoopRunSpecific + 384
20 GraphicsServices 0x184bf8088 GSEventRunModal + 180
21 UIKit 0x188560d90 UIApplicationMain + 204
22 Matura 0x1000c5748 main (EngleskiPitanja.swift:15)
23 libdispatch.dylib 0x18328a8b8 (Missing)
#1. com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x1833a94fc kevent_qos + 8
1 libdispatch.dylib 0x18326c94c _dispatch_mgr_invoke + 232
2 libdispatch.dylib 0x18325b7bc _dispatch_source_invoke + 50
#2. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#3. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#4. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#5. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#6. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#7. com.twitter.crashlytics.ios.MachExceptionServer
0 Matura 0x10013615c CLSProcessRecordAllThreads (CLSProcess.c:376)
1 Matura 0x10013615c CLSProcessRecordAllThreads (CLSProcess.c:376)
2 Matura 0x10013600c CLSProcessRecordAllThreads (CLSProcess.c:407)
3 Matura 0x1001262b0 CLSHandler (CLSHandler.m:26)
4 Matura 0x100121278 CLSMachExceptionServer (CLSMachException.c:446)
5 libsystem_pthread.dylib 0x18346fb28 _pthread_body + 156
6 libsystem_pthread.dylib 0x18346fa8c _pthread_body + 154
7 libsystem_pthread.dylib 0x18346d028 thread_start + 4
#8. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#9. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#10. com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x18338d4bc mach_msg_trap + 8
1 libsystem_kernel.dylib 0x18338d338 mach_msg + 72
2 CoreFoundation 0x1837bcac0 __CFRunLoopServiceMachPort + 196
3 CoreFoundation 0x1837ba7c4 __CFRunLoopRun + 1032
4 CoreFoundation 0x1836e9680 CFRunLoopRunSpecific + 384
5 CFNetwork 0x183e59434 +[NSURLConnection(Loader) _resourceLoadLoop:] + 412
6 Foundation 0x1841c7c40 __NSThread__start__ + 1000
7 libsystem_pthread.dylib 0x18346fb28 _pthread_body + 156
8 libsystem_pthread.dylib 0x18346fa8c _pthread_body + 154
9 libsystem_pthread.dylib 0x18346d028 thread_start + 4
#11. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#12. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#13. Thread
0 libsystem_kernel.dylib 0x1833a8b6c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x18346d530 _pthread_wqthread + 1284
2 libsystem_pthread.dylib 0x18346d020 start_wqthread + 4
#14. com.apple.CFSocket.private
0 libsystem_kernel.dylib 0x1833a8368 __select + 8
1 CoreFoundation 0x1837c3028 __CFSocketManager + 648
2 libsystem_pthread.dylib 0x18346fb28 _pthread_body + 156
3 libsystem_pthread.dylib 0x18346fa8c _pthread_body + 154
4 libsystem_pthread.dylib 0x18346d028 thread_start + 4
是否要说这个班级" EngleskiPitanja"不见了?如果是这样,我不明白为什么,因为它在项目中。
这是导致崩溃的方法
func getRealmObjectBasedOnString(type: String) -> Object.Type?{
guard let objectType = NSClassFromString("Matura.\(type)") else {
//print("fail \(type)")
return nil
}
return objectType as? Object.Type
}