【问题标题】:Value of optional type 'NSURL?' not unwrapped; did you mean to use '!' or '?'?可选类型 'NSURL?' 的值未拆封;你的意思是用'!'或者 '?'?
【发布时间】:2014-09-11 12:32:48
【问题描述】:

我使用 Xcode 6 Beta 6 开始了一个 Swift 项目。该项目还使用了 Core Data。升级到 Xcode 6 GM 后,编译时出现以下错误:

/Users/.../AppDelegate.swift:58:52: Value of optional type 'NSURL?' not unwrapped; did you mean to use '!' or '?'?

错误的代码行是:

return NSManagedObjectModel(contentsOfURL: modelURL)

知道发生了什么变化吗?

【问题讨论】:

    标签: swift


    【解决方案1】:

    好的,我刚刚使用 '!' 解开可选的包装,现在正在编译代码。

    return NSManagedObjectModel(contentsOfURL: modelURL!)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 2015-11-11
      • 1970-01-01
      • 2018-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多