Swift nw_host_stats_add_src收到SRC_ADDED的错误:[22]无效的参数

时间:2018-03-26 13:47:06

标签: ios swift

此应用程序启动时仅在iOS 10.1.1上发生此错误,此处为backtrace:

dumping backtrace:

    [x86_64] libnetcore-856.20.4
0   libsystem_network.dylib             0x000000010db07682 __nw_create_backtrace_string + 123
1   libsystem_network.dylib             0x000000010db1e306 nw_get_host_stats + 1083
2   libnetwork.dylib                    0x000000010ddfd78b nw_endpoint_resolver_start_next_child + 1382
3   libdispatch.dylib                   0x000000010d884980 _dispatch_call_block_and_release + 12
4   libdispatch.dylib                   0x000000010d8ae0cd _dispatch_client_callout + 8
5   libdispatch.dylib                   0x000000010d88be6b _dispatch_queue_serial_drain + 236
6   libdispatch.dylib                   0x000000010d88cb9f _dispatch_queue_invoke + 1073
7   libdispatch.dylib                   0x000000010d88f3b7 _dispatch_root_queue_drain + 720
8   libdispatch.dylib                   0x000000010d88f08b _dispatch_worker_thread3 + 123
9   libsystem_pthread.dylib             0x000000010dc611ca _pthread_wqthread + 1387
10  libsystem_pthread.dylib             0x000000010dc60c4d start_wqthread + 13

AppDelegate中:         func application(_ application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey:Any]?) - >布尔{         //在应用程序启动后覆盖自定义点。

    let center = UNUserNotificationCenter.current()
    center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
        guard granted else{return}

        self.getNotificationSettings()

    }
    Fabric.with([Crashlytics.self])
    UNUserNotificationCenter.current().delegate = self

    application.registerForRemoteNotifications()

    initDb()
    startReachability()
    initKeyboardManager()
    slideMenuController = slideMenuWithNavigationController()
    slideMenuController.removeLeftGestures()
    self.window?.rootViewController = slideMenuController
    self.window?.makeKeyAndVisible()
    return true
}

  private func slideMenuWithNavigationController() -> SlideMenuController {
    let storyboard = UIStoryboard(name: "LeftMenu", bundle: nil)
    let startStoryboard = UIStoryboard(name: "Start", bundle: nil)
    let firstVC = startStoryboard.instantiateViewController(withIdentifier: "StartVC")
    navController = UINavigationController(rootViewController: firstVC)
    navController.interactivePopGestureRecognizer?.isEnabled = false
    let sideBar = storyboard.instantiateViewController(withIdentifier: "LeftMenuVC")

    SlideMenuOptions.leftViewWidth = 270//Config.LEFT_MENU_WIDTH
    SlideMenuOptions.simultaneousGestureRecognizers = false
    return SlideMenuController( mainViewController: navController, leftMenuViewController: sideBar)
}
func initDb(){
    let storeName = "DataModel.sqlite"
    MagicalRecord.setLoggingLevel(MagicalRecordLoggingLevel.verbose)
    MagicalRecord.setupCoreDataStack(withStoreNamed: storeName)
}
func startReachability(){
    do {
        reachability = Reachability.init()//try reachability!.reachabilityForInternetConnection()
        reachability!.whenReachable = { reachability in
            self.isConnectedToInternet = true
        }
        reachability!.whenUnreachable = { reachability in
            self.isConnectedToInternet = false
        }
        try reachability!.startNotifier()
    } catch {
        print("Unable to create Reachability")
        return
    }
}
func initKeyboardManager(){
    IQKeyboardManager.sharedManager().enable = true
    IQKeyboardManager.sharedManager().shouldResignOnTouchOutside = true
    IQKeyboardManager.sharedManager().enableAutoToolbar = true
    IQKeyboardManager.sharedManager().shouldShowToolbarPlaceholder = false
    IQKeyboardManager.sharedManager().preventShowingBottomBlankSpace = true
}

func getNotificationSettings() {
    UNUserNotificationCenter.current().getNotificationSettings { (settings) in
        print("Notification settings: \(settings)")
        guard settings.authorizationStatus == .authorized else {return}
        DispatchQueue.main.async {
            UIApplication.shared.registerForRemoteNotifications()
        }

    }
}

0 个答案:

没有答案