最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

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

iOS crifan 911浏览 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,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
63 queries in 0.122 seconds, using 18.70MB memory