【发布时间】:2018-11-24 04:51:02
【问题描述】:
我需要帮助。从 Swift 2.3 -> 3.2 转换时,我收到以下错误。我无法解决此错误。
以下是我的编码资料,我遇到了一些问题。
Error1:无法将 String 类型的值转换为指定类型 NSManagedObjectContext**
错误 2:无法将类型 URL 的返回表达式转换为返回类型 URL。
class func persistentFileURL(_ name: String, enclosingDirectoryName: String) -> Foundation.URL {
let directoryURL = self.directoryForPersistentStorage(enclosingDirectoryName)
let urlPath = directoryURL.path
let filePath: NSManagedObjectContext = (urlPath as NSString).appendingPathComponent(name) //Error1 : Cannot convert value of type String to specified type NSManagedObjectContext
return URL(context: filePath) // Error2 : Cannot convert return expression of type URL to return type URL.
}
注意:URL 是单独的类声明来处理这个问题:URL_Class
请帮助我。我对 iOS 很陌生。无法理解此类错误。
【问题讨论】:
标签: ios swift swift2.3 swift3.2