将我的项目升级到Swift 2.1后,'Curl error: error: 1408D13A:SSL routines: SSL3_GET_KEY_EXCHANGE:unable to find ecdh parameters.
NSFileManger
会抛出以下错误。
copyItemAtPath
底层源文件和目标文件夹都存在,但副本始终失败。
Error Domain=NSCocoaErrorDomain Code=260 "The file "Settings.plist" couldn’t be opened because there is no such file."
NSFilePath=/Users/nick/Library/Developer/CoreSimulator/Devices/95856F10-9770-44B5-B990-B461E6991B79/data/Containers/Bundle/Application/17AAAD05-33FE-470A-9617-C8E378371E2E/MyApp.app/Settings.plist,
NSDestinationFilePath=/Users/nick/Library/Developer/CoreSimulator/Devices/95856F10-9770-44B5-B990-B461E6991B79/data/Containers/Data/Application/020503D6-F7CE-47D2-83A7-D4B7D86E6D1D/Documents/Settings.plist,
NSUnderlyingError=0x7994daf0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
文件存在且let _documentsDirectory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
let storePath = NSURL(fileURLWithPath: _documentsDirectory).URLByAppendingPathComponent("\(storeName).plist").absoluteString
let fileManager = NSFileManager.defaultManager()
if (!fileManager.fileExistsAtPath(storePath)) {
if let bundle = NSBundle.mainBundle().pathForResource(storeName, ofType:"plist") {
do {
try fileManager.copyItemAtPath(bundle, toPath: storePath)
return storePath
} catch let error as NSError {
print(error)
return nil
}
}...
返回true。
审核后 How to find NSDocumentDirectory in swift?和其他人,我已经尝试了许多不同的方法来获取Documents目录和主要的bundle资源,但我无法获取要复制的文件。
一切都在Swift 1.2中完美运行。