Sample code for 30+ languages & platforms
Swift

Example: Http.QuickGetStr method

Demonstrates the QuickGetStr method.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    let http = CkoHttp()!

    // Keep the response body if there's an error.
    http.keepResponseBody = true

    // Send the HTTP GET and return the content in a string.
    var str: String? = http.quickGetStr(url: "https://www.chilkatsoft.com/helloWorld.json")
    if http.lastMethodSuccess == false {
        if http.lastStatus.intValue == 0 {
            // Communications error.  We did not get a response.
            print("\(http.lastErrorText!)")
        }
        else {
            print("Response status code: \(http.lastStatus.intValue)")
            print("Response body error text:")
            print("\(http.lastResponseBody!)")
        }

        return
    }

    print("\(str!)")
    print("Success")

}