Sample code for 30+ languages & platforms
Swift

Transition from Zip.AppendDataEncoded to Zip.AddEncoded

Provides instructions for replacing deprecated AppendDataEncoded method calls with AddEncoded.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let zip = CkoZip()!

    // ...
    // ...
    var pathInZip: String? = "example.dat"
    var encoding: String? = "base64"
    var encData: String? = "... BASE64 DATA ..."

    // ------------------------------------------------------------------------
    // The AppendDataEncoded method is deprecated:

    var entryObj: CkoZipEntry? = zip.appendDataEncoded(filename: pathInZip, encoding: encoding, data: encData)
    if zip.lastMethodSuccess == false {
        print("\(zip.lastErrorText!)")
        return
    }

    // ...
    // ...

    entryObj = nil

    // ------------------------------------------------------------------------
    // Do the equivalent using AddEncoded.

    // Instead of returning the zip entry object, we just return success/failure.
    success = zip.addEncoded(pathInZip: pathInZip, encoding: encoding, data: encData)
    if success == false {
        print("\(zip.lastErrorText!)")
        return
    }

    // Do the following if you need the zip entry object for what was just appended.
    // The newly appended entry is the last one.
    let ze = CkoZipEntry()!
    var index: Int = zip.numEntries.intValue - 1
    zip.entry(at: index, entry: ze)

}