[英]Swift Project Terminating with uncaught exception of type NSException
[英]AppDelegate didFinishLaunchingWithOptions launchOptions - terminating with uncaught exception of type NSException Swift 3.0
我正在尝试使用Swift 3.0创建登录/受保护的页面会话页面
因此,我在AppDelegate.swift中创建了didFinishLaunchingWithOptions launchOptions函数,如下所示
AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let rootViewController = self.window!.rootViewController
let mainStoryBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let isUserLoggedIn:Bool = UserDefaults.standard.bool(forKey: "isUserLoggedIn")
if(!isUserLoggedIn){
let loginViewController = mainStoryBoard.instantiateViewController(withIdentifier: "loginview") as! LoginVC
window!.rootViewController = loginViewController
window!.makeKeyAndVisible()
}
else{
let protectedPage = mainStoryBoard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
window!.rootViewController = protectedPage
window!.makeKeyAndVisible()
}
return true
}
}
它构建成功,但是运行应用程序时出现错误。 错误如下
由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“ Storyboard()不包含标识符为“ loginview”的视图控制器
libc ++ abi.dylib:以类型为NSException(lldb)的未捕获异常终止
在情节提要中选择LoginVC,然后在检查器窗口中的情节提要ID中提供loginview
标识符
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.