Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 类型为'的值;数据';没有成员';writeToURL';_Ios_Swift_Cordova - Fatal编程技术网

Ios 类型为'的值;数据';没有成员';writeToURL';

Ios 类型为'的值;数据';没有成员';writeToURL';,ios,swift,cordova,Ios,Swift,Cordova,我正在将代码转换为swift 3语法 if !data.writeToURL(manifestFileURL, atomically: false) { self.didFailWithError(WebAppError.fileSystemFailure(reason: "Could not write asset manifest to: \(manifestFileURL)", underlyingError: error)) return } 但是我得到了错误

我正在将代码转换为swift 3语法

if !data.writeToURL(manifestFileURL, atomically: false) {
      self.didFailWithError(WebAppError.fileSystemFailure(reason: "Could not write asset manifest to: \(manifestFileURL)", underlyingError: error))
      return
}
但是我得到了错误

类型“Data”的值没有成员“writeToURL”

我已将代码转换为

if try!data.write(to: manifestFileURL, atomically: false) {
      self.didFailWithError(WebAppError.fileSystemFailure(reason: "Could not write asset manifest to: \(manifestFileURL)", underlyingError: error))
      return
}
遵循swift 3语法和当前方法(),但我收到错误消息说这不是函数的正确重载。请问,在swift 3中写出来的正确方式是什么。任何能引导我走向正确方向的信息都将不胜感激

谢谢

它已被重命名为:

试试看!data.write(到:manifestFileURL,选项:[.atomic])
使用


原子性:false
等于无选项,您可以忽略该参数

所以这很简单

do {
    try data.write(to: manifestFileURL)
} catch let error as NSError {
    self.didFailWithError(WebAppError.fileSystemFailure(reason: "Could not write asset manifest to: \(manifestFileURL)", underlyingError: error))
}

catch子句处理错误。

它现在说:“()”不能转换为“Bool”,它不会返回
Bool
,现在它的handled by error抛出,只需删除Bool check,它现在就说明:callstatic成员“atomic”中的额外参数“options”不能用于类型为“NSData.writingations”的实例,现在我的答案不再有显著差异;-)你的答案很完美。我遗漏了一些东西,这就是为什么我要更新它。我也会在《捕获:p》中回来
do {
    try data.write(to: manifestFileURL)
} catch let error as NSError {
    self.didFailWithError(WebAppError.fileSystemFailure(reason: "Could not write asset manifest to: \(manifestFileURL)", underlyingError: error))
}