Xcode更新到7.3后断言失败

时间:2016-03-24 10:34:10

标签: ios xcode swift xcode7.3

我将Xcode更新为7.3。在更新之前,我能够运行任何错误或崩溃的代码。更新后,当我在iPhone上运行以下代码时,我得到断言错误(在模拟器上有趣的没有错误)。

let storyboard =  UIStoryboard(name: storyboard, bundle: nil)
self.window?.rootViewController = storyboard.instantiateInitialViewController() as UIViewController!

错误

2016-03-24 16:15:25.891 Zilingo[434:92251] *** Assertion failure in -[UIStoryboard instantiateViewControllerWithIdentifier:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.7/UIStoryboard.m:171
error: Execution was interrupted, reason: breakpoint 5.1.
The process has been returned to the state before expression evaluation.

我错过了更新的一些步骤吗?

2 个答案:

答案 0 :(得分:1)

Try to this format:-   

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

   // get your storyboard
   let storyboard = UIStoryboard(name: "Main", bundle: nil)

   // instantiate your desired ViewController
   let rootController = storyboard.instantiateViewControllerWithIdentifier("MyViewController") as! UIViewController

   // Because self.window is an optional you should check it's value first and assign your rootViewController
   if let window = self.window {
      window.rootViewController = rootController
   }

   return true
}

答案 1 :(得分:0)

我遇到了同样的问题。就我而言,我忘记添加标识符字符串。 让 vc = storyboard.instantiateViewControllerWithIdentifier("") 为! UIViewController

我像上面那样写。我忘了添加标识符。在我添加标识符后,它起作用了。