最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift中出错:Extra argument error in call

iOS crifan 2960浏览 0评论

代码:

    func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {

        let download = self.downloads[downloadTask.taskIdentifier]!

        var fileError: NSError?

        var resultingURL: NSURL?

        if NSFileManager.defaultManager().replaceItemAtURL(download.destinationURL, withItemAtURL: location, backupItemName: nil, options: nil, resultingItemURL: &resultingURL, error: &fileError) {

            download.resultingURL = resultingURL

        } else {

            download.error = fileError

        }

       

    }

出错:

/Users/crifan/dev/dev_root/daryun/JianDao/iOS-Client/JianDao/TCBlobDownloadManager.swift:180:185: Extra argument ‘error’ in call

extra argument ‘error’ in call swift

ios – Swift 2 Extra argument ‘ error’ in call – Stack Overflow

改为:

//        if NSFileManager.defaultManager().replaceItemAtURL(download.destinationURL, withItemAtURL: location, backupItemName: nil, options: nil, resultingItemURL: &resultingURL, error: &fileError) {

//            download.resultingURL = resultingURL

//        } else {

//            download.error = fileError

//        }

       

        do {

            try NSFileManager.defaultManager().replaceItemAtURL(download.destinationURL, withItemAtURL: location, backupItemName: nil, options: nil, resultingItemURL: &resultingURL)

           

            download.resultingURL = resultingURL

        } catch let error as NSError {

            download.error = error

        }

结果又出错:

[已解决]swift出错:Nil is not compatible with expected argument type NSFileManagerItemReplacementOptions

转载请注明:在路上 » [已解决]swift中出错:Extra argument error in call

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.209 seconds, using 22.08MB memory