问题 AppDelegate 与新的 Swift 2.2 / Xcode 7.3.1



我最近升级了Xcode并尝试继续编程。无法构建我的应用。它说问题出在应用程序代表中。我复制我的代码:

import UIKit

@UIApplicationMain
AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
        let defaults = NSUserDefaults.standardUserDefaults()
        var rootViewController : UIViewController;
        if (defaults.boolForKey("HasBeenLaunched")) {
            // This gets executed if the app has ALREADY been launched
            rootViewController = storyboard.instantiateViewControllerWithIdentifier("maintabcontroller") as UIViewController
        } else {
            // This gets executed if the app has NEVER been launched
            defaults.setBool(true, forKey: "HasBeenLaunched")
            defaults.synchronize()
            rootViewController = storyboard.instantiateViewControllerWithIdentifier("setupstory") as UIViewController
        }
        window?.rootViewController = rootViewController;
        window?.makeKeyAndVisible();
        UITabBar.appearance().barTintColor = UIColor.whiteColor()
        UITabBar.appearance().tintColor = UIColor.blackColor()
        return true
    }
}

错误在行AppDelegate: UIResponder, UIApplicationDelegate { 中。它们是:

  • 预期声明
  • 语句不能以闭包表达式开头
  • 顶级不允许使用表达式
  • 大括号语句块是未使用的
  • 表达式解析为未使用的函数

在升级之前,我没有收到所有这些错误。

您不小心删除了class关键字:

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

相关内容

  • 没有找到相关文章

最新更新