【发布时间】:2016-06-12 14:46:34
【问题描述】:
我最近升级了 Xcode 并尝试继续编程。我的应用程序无法构建。它说问题出在 AppDelegate 中。 我复制我的代码:
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 { 行中。它们是:
- 预期声明
- 语句不能以闭包表达式开头
- 不允许在顶层使用表达式
- 大括号语句块未使用
- 表达式解析为未使用的函数
在升级之前,我没有遇到所有这些错误。
【问题讨论】:
-
您在
AppDelegate: UIResponder, UIApplicationDelegate {之前缺少一个“class” -
您可以创建一个新的空项目并查看您的项目中缺少什么。
标签: ios xcode swift appdelegate xcode7.3