Sample code for 30+ languages & platforms
Swift

Transition from Http.PostBinary to Http.HttpBinary

Provides instructions for replacing deprecated PostBinary method calls with HttpBinary.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let http = CkoHttp()!

    var verb: String? = "POST"
    var url: String? = "https://example.com/"
    var byteData: NSData
    var contentType: String? = "application/octet-stream"

    // ------------------------------------------------------------------------
    // The PostBinary method is deprecated:

    var responseBody: String? = http.postBinary(url: url, byteData: byteData, contentType: contentType, md5: false, gzip: false)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    // ...
    // ...

    // ------------------------------------------------------------------------
    // Do the equivalent using HttpBinary.

    let responseOut = CkoHttpResponse()!
    success = http.httpBinary(verb: verb, url: url, byteData: byteData, contentType: contentType, response: responseOut)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    responseBody = responseOut.bodyStr

}