Я получаю крэ sh в Фабри c Crashlytics. Вот отчет cra sh:
#0. Crashed: com.apple.main-thread
0 myAppName 0xcb79a closure #1 in closure #1 in homeTabBar.getNotificationListFromServer() + 93 (homeTabBar.swift:93)
1 myAppName 0xcb795 closure #1 in closure #1 in homeTabBar.getNotificationListFromServer() + 93 (homeTabBar.swift:93)
2 myAppName 0xe4b37 thunk for @escaping @callee_guaranteed () -> () + 1276727 (<compiler-generated>:1276727)
3 libdispatch.dylib 0x1d02d797 _dispatch_call_block_and_release + 10
4 libdispatch.dylib 0x1d02d783 _dispatch_client_callout + 22
5 libdispatch.dylib 0x1d031d05 _dispatch_main_queue_callback_4CF + 902
6 CoreFoundation 0x1d91bd69 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
7 CoreFoundation 0x1d919e19 __CFRunLoopRun + 848
8 CoreFoundation 0x1d86d1af CFRunLoopRunSpecific + 470
9 CoreFoundation 0x1d86cfd1 CFRunLoopRunInMode + 104
10 GraphicsServices 0x1f017b41 GSEventRunModal + 80
11 UIKit 0x22bf5a53 UIApplicationMain + 150
12 myAppName 0x85d4b main + 24 (AppDelegate.swift:24)
13 libdyld.dylib 0x1d05a4eb start + 2
#1. APMAnalyticsQueue
0 libsystem_kernel.dylib 0x1d12c568 __bsdthread_ctl + 12
1 libsystem_pthread.dylib 0x1d1e83bf _pthread_qos_override_end_direct + 16
2 libobjc.A.dylib 0x1cbeedd5 rwlock_tt<false>::unlockRead() + 44
3 libobjc.A.dylib 0x1cbeed07 lookUpImpOrForward + 414
4 libobjc.A.dylib 0x1cbeeb35 lookUpImpOrNil + 22
5 libobjc.A.dylib 0x1cbe64cf class_respondsToSelector_inst + 24
6 libobjc.A.dylib 0x1cc01cfd -[NSObject respondsToSelector:] + 36
7 GoogleUtilities 0x2b6bbd9 -[GULNetwork setLoggerDelegate:] + 92
8 myAppName 0x23aec5 -[APMMeasurement initWithAppID:isAnalyticsCollectionEnabled:isAnalyticsCollectionDeactivated:safelistedEvents:] + 2678469
9 myAppName 0x238747 +[APMMeasurement initializeSharedInstanceWithAppID:isAnalyticsCollectionEnabled:isAnalyticsCollectionDeactivated:safelistedEvents:] + 2668359
10 myAppName 0x222947 __46+[APMAnalytics startWithAppID:origin:options:]_block_invoke_2 + 2578759
11 libdispatch.dylib 0x1d02d797 _dispatch_call_block_and_release + 10
12 libdispatch.dylib 0x1d03a59d _dispatch_queue_serial_drain + 854
13 libdispatch.dylib 0x1d030b71 _dispatch_queue_invoke + 886
14 libdispatch.dylib 0x1d03c1b5 _dispatch_root_queue_drain + 326
15 libdispatch.dylib 0x1d03c00f _dispatch_worker_thread3 + 106
16 libsystem_pthread.dylib 0x1d1e287d _pthread_wqthread + 1040
17 libsystem_pthread.dylib 0x1d1e245c start_wqthread + 8
homeTabBar - это UITabbarConroller. Вот фрагмент кода, который содержит номер строки cra sh, указанный в отчете fabri c cra sh.
func getNotificationListFromServer(){
WebServices.shared.getNotificationList(success: {result in
do {
if let arrayData = try JSONSerialization.jsonObject(with: result, options: .allowFragments) as? NSArray {
Global.arrayNotificationList = arrayData.mutableCopy() as? NSMutableArray
DispatchQueue.main.async {
if self.selectedIndex == 0{
let nav = self.viewControllers?[0] as! UINavigationController
let vc = nav.viewControllers[0] as! ScanTabVC
Functions.AddNotificationButton(viewController: vc, headerView: vc.headerView, isUnReadMessage: false)
} else if self.selectedIndex == 1{
let nav = self.viewControllers?[1] as! UINavigationController
let vc = nav.viewControllers[0] as! FormsTabVC
Functions.AddNotificationButton(viewController: vc, headerView: vc.headerView, isUnReadMessage: false)
}else if self.selectedIndex == 2{ // **crash cause line number**
let nav = self.viewControllers?[2] as! UINavigationController
let vc = nav.viewControllers[0] as! TasksTabVC
Functions.AddNotificationButton(viewController: vc, headerView: vc.headerView, isUnReadMessage: false)
}
}
}
}catch
{
print("some error")
}
}, failure: {error in
print(error)
})
}
В моем проекте целевой экран проекта определяется сервером, поэтому мне нужно программно установить выбранный индекс как:
class homeTabBar: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.0) {
if AppDelegate.appDelegate.landingScreen == "2" {
self.selectedIndex = 1
} else if AppDelegate.appDelegate.landingScreen == "3" {
self.selectedIndex = 2
} else {
self.selectedIndex = 0
}
}
tabBar.items?[0].title = NSLocalizedString("First", comment: "")
tabBar.items?[1].title = NSLocalizedString("Second", comment: "")
tabBar.items?[2].title = NSLocalizedString("Third", comment: "")
tabBar.items?[3].title = NSLocalizedString("Fourth", comment: "")
getNotificationListFromServer() } }
Cra sh не тиражируется. Как я могу решить это или повторить это. Cra sh сообщается от iPhone 5 c и iOS 10.3.3 (14G60). Заранее спасибо.