在应用启动期间继续在iOS 9.3上崩溃

时间:2018-02-22 06:31:25

标签: ios swift xcode

我在这3个屏幕截图中显示了我遇到的错误。几乎我是应用程序开发的新手,这是我的第一个应用程序。在iOS 11上它工作正常但在iOS 9.3到iOS 10.3上它在启动屏幕上崩溃。我已经完成了我能在网上找到的所有东西,但没有运气。有人请帮忙。我正在运行Xcode 9 / Swift 4.谢谢

第二行是给我“线程1:信号SIGABRT”错误

@UIApplicationMain 

class AppDelegate: UIResponder, UIApplicationDelegate {


 var window: UIWindow?
 var stationsViewController: StationsViewController?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    // MPNowPlayingInfoCenter
    UIApplication.shared.beginReceivingRemoteControlEvents()

    // Make status bar white
    UINavigationBar.appearance().barStyle = .black

    // FRadioPlayer config
    FRadioPlayer.shared.artworkSize = 600

    // Get weak ref of StationsViewController
    if let navigationController = window?.rootViewController as? UINavigationController {
        stationsViewController = navigationController.viewControllers.first as? StationsViewController

    let onesignalInitSettings = [kOSSettingsKeyAutoPrompt: false]

    // Replace 'YOUR_APP_ID' with your OneSignal App ID.
    OneSignal.initWithLaunchOptions(launchOptions,
                                    appId: "224ba355-0ceb-4d89-9759-46c61a62c7c1",
                                    handleNotificationAction: nil,
                                    settings: onesignalInitSettings)

    OneSignal.inFocusDisplayType = OSNotificationDisplayType.notification;

    // Recommend moving the below line to prompt for push after informing the user about
    //   how your app will use them.
    OneSignal.promptForPushNotifications(userResponse: { accepted in
        print("User accepted notifications: \(accepted)")
    })

    // Sync hashed email if you have a login system or collect it.
    //   Will be used to reach the user at the most optimal time of day.
    // OneSignal.syncHashedEmail(userEmail)

    }
    return true
}

func applicationWillResignActive(_ application: UIApplication) {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

}

func applicationDidEnterBackground(_ application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.


}

func applicationWillEnterForeground(_ application: UIApplication) {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

}

func applicationDidBecomeActive(_ application: UIApplication) {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.


}

func applicationWillTerminate(_ application: UIApplication) {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    // Saves changes in the application's managed object context before the application terminates.

    UIApplication.shared.endReceivingRemoteControlEvents()

}

// MARK: - Remote Controls

override func remoteControlReceived(with event: UIEvent?) {
   super.remoteControlReceived(with: event)

    guard let event = event, event.type == UIEventType.remoteControl else { return }

    switch event.subtype {
    case .remoteControlPlay:
        FRadioPlayer.shared.play()
    case .remoteControlPause:
        FRadioPlayer.shared.pause()
    case .remoteControlTogglePlayPause:
        FRadioPlayer.shared.togglePlaying()
    case .remoteControlNextTrack:
        stationsViewController?.didPressNextButton()
    case .remoteControlPreviousTrack:
        stationsViewController?.didPressPreviousButton()
    default:
        break
    }
}

Error Screenshot 1

Error Screenshot 2

Error Screenshot 3

0 个答案:

没有答案