【问题标题】:alamofire complains about argument typealamofire 抱怨参数类型
【发布时间】:2015-08-11 03:39:53
【问题描述】:

我正在使用 alamofire 主分支。

我按照git页面中的官方教程编写以下代码。

我的代码是这样的:

private func startDownLoad() {
    Alamofire.download(.GET, REMOTE_TESTSET_URL,
        { (temporaryURL, response) in
            if let directoryURL = NSFileManager.defaultManager().URLsForDirectory(
                .DocumentDirectory, inDomains: .UserDomainMask)[0] as? NSURL {
                    let pathComponent = response.suggestedFilename
                    let fileUrl = directoryURL.URLByAppendingPathComponent(pathComponent!)
                    if let fullPath = fileUrl.absoluteString {
                        if NSFileManager.defaultManager().fileExistsAtPath(fullPath) {
                            NSFileManager.defaultManager().removeItemAtPath(fullPath, error: nil)
                        }
                    }
                    return fileUrl
            }
            return temporaryURL
        }
    ).progress( closure: { (bytesRead, totalBytesRead, totalBytesExpectedToRead) in
            println("download set progress")
            self.delegate.onDownLoadProgress(Int(totalBytesRead), total: Int(totalBytesExpectedToRead))
    }).response { (request, response, _, error) in
        if nil == error {
            NSUserDefaults.standardUserDefaults().setValue(self.currentVersion, forKey: KEY_TEST_SET_VERSION)
            self.delegate.onDownLoadFinish(STATUS_DOWNLOAD_SUCCESS)
        } else {
            self.delegate.onDownLoadError(ERROR_UNKNOWN_ERROR)
        }
    }
}

但是编译器抱怨:

“无法使用类型为 '((_, _, _, _) -> _) 的参数列表调用 'response'”

那么,有什么想法吗?谢谢。

【问题讨论】:

  • 会不会是因为在“response”和“progress”参数中,你多放了(),设置是参数列表?
  • 恐怕不行。我删除( ),但错误仍然存​​在

标签: swift alamofire


【解决方案1】:

您在 Alamofire.download 方法中的闭包上缺少 destination 参数。

【讨论】:

  • 真的很感激!
猜你喜欢
  • 2015-07-02
  • 1970-01-01
  • 1970-01-01
  • 2013-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-17
  • 1970-01-01
相关资源
最近更新 更多