li_shengdm
li_shengdm

Reputation: 43

alamofire complains about argument type

I'm using alamofire master branch.

I write the following code as official tutorial said in the git page. enter image description here

My code is something like:

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)
        }
    }
}

But the compiler complains:

"Cannot invoke 'response' with an argument list of type '((_, _, _, _) -> _)"

so, any ideas? thanks.

Upvotes: 1

Views: 107

Answers (1)

cnoon
cnoon

Reputation: 16643

You are missing the destination parameter on your closure in the Alamofire.download method.

Upvotes: 1

Related Questions