Sample code for 30+ languages & platforms
Swift

Transition from Zip.AppendNewDir to Zip.AddEmpty

Provides instructions for replacing deprecated AppendNewDir method calls with AddEmpty.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let zip = CkoZip()!

    // ...
    // ...
    var pathInZip: String? = "exampleDir"

    // ------------------------------------------------------------------------
    // The AppendNewDir method is deprecated:

    var entryObj: CkoZipEntry? = zip.appendNewDir(pathInZip: pathInZip)
    if zip.lastMethodSuccess == false {
        print("\(zip.lastErrorText!)")
        return
    }

    // ...
    // ...

    entryObj = nil

    // ------------------------------------------------------------------------
    // Do the equivalent using AddEmpty.

    // Indicate the newly appended entry is a directory entry.
    var isDir: Bool = true

    // Instead of returning the zip entry object, we just return success/failure.
    success = zip.addEmpty(isDir: isDir, pathInZip: pathInZip)
    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)

}