Swift
Swift
Transition from Http.PBinary to Http.HttpBinary
See more HTTP Examples
Provides instructions for replacing deprecated PBinary method calls with HttpBinary.Chilkat Swift Downloads
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 PBinary method is deprecated:
var responseObj: CkoHttpResponse? = http.pBinary(verb: verb, url: url, byteData: byteData, contentType: contentType, md5: false, gzip: false)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
// ...
// ...
responseObj = nil
// ------------------------------------------------------------------------
// Do the equivalent using HttpBinary.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
let responseOut = CkoHttpResponse()!
success = http.httpBinary(verb: verb, url: url, byteData: byteData, contentType: contentType, response: responseOut)
if success == false {
print("\(http.lastErrorText!)")
return
}
}