Sample code for 30+ languages & platforms
Swift Requires Chilkat v11.7.0+

Get the QR Code Capabilities of the Chilkat Version in Use

See more QR Code Examples

Demonstrates the capabilities operation, which describes what the installed version of Chilkat can do: the range of QR versions, the error-correction levels, the operations, the image formats and the limits. A program can check for a feature here instead of testing for a Chilkat version number. The request can be an empty JSON object.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    let json = CkoJsonObject()!
    let fmt = CkoFormats()!
    let jsonOut = CkoJsonObject()!
    success = fmt.qrCode(op: "capabilities", jsonIn: json, jsonOut: jsonOut)
    if success == false {
        print("\(fmt.lastErrorText!)")
        return
    }

    print("Chilkat version: \(jsonOut.string(of: "productVersion")!)")
    print("symbology: \(jsonOut.string(of: "symbologies[0].id")!)")
    print("QR versions: \(jsonOut.int(of: "symbologies[0].encoding.version.min").intValue) to \(jsonOut.int(of: "symbologies[0].encoding.version.max").intValue)")
    print("structured append, most symbols: \(jsonOut.int(of: "symbologies[0].structuredAppend.maxSymbols").intValue)")

    var i: Int
    var n: Int
    n = jsonOut.size(ofArray: "symbologies[0].encoding.errorCorrection").intValue
    for i = 0; i <= n - 1; i++ {
        jsonOut.i = i
        print("error correction: \(jsonOut.string(of: "symbologies[0].encoding.errorCorrection[i]")!)")
    }

    //  The operations this version implements.
    n = jsonOut.size(ofArray: "operations").intValue
    for i = 0; i <= n - 1; i++ {
        jsonOut.i = i
        if jsonOut.bool(of: "operations[i].available") == true {
            print("operation: \(jsonOut.string(of: "operations[i].name")!)")
        }

    }

    n = jsonOut.size(ofArray: "imageFormats.output").intValue
    for i = 0; i <= n - 1; i++ {
        jsonOut.i = i
        print("image format: \(jsonOut.string(of: "imageFormats.output[i]")!)")
    }

    print("default timeout: \(jsonOut.int(of: "limits.timeoutMs.default").intValue) ms")
    print("default largest image: \(jsonOut.int(of: "limits.maxPixels.default").intValue) pixels")

    //  Sample output:

    //  Chilkat version: 11.7.0
    //  symbology: qr
    //  QR versions: 1 to 40
    //  structured append, most symbols: 16
    //  error correction: auto
    //  error correction: L
    //  error correction: M
    //  error correction: Q
    //  error correction: H
    //  operation: generate
    //  operation: measure
    //  operation: validate
    //  operation: capabilities
    //  image format: png
    //  image format: svg
    //  default timeout: 10000 ms
    //  default largest image: 16777216 pixels

}