Sample code for 30+ languages & platforms
Swift

Transition from Imap.Sort to Imap.QueryMbx

Provides instructions for replacing deprecated Sort method calls with QueryMbx.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let imap = CkoImap()!

    // ...
    // ...

    var searchCriteria: String? = "FROM bob@example.com"
    var bUid: Bool = true
    var sortCriteria: String? = "DATE SUBJECT"

    // ------------------------------------------------------------------------
    // The Sort method is deprecated:

    var msgSetObj: CkoMessageSet? = imap.sort(sortCriteria: sortCriteria, charset: "UTF-8", searchCriteria: searchCriteria, bUid: bUid)
    if imap.lastMethodSuccess == false {
        print("\(imap.lastErrorText!)")
        return
    }

    // ...
    // ...

    msgSetObj = nil

    // ------------------------------------------------------------------------
    // Do the equivalent using QueryMbx.
    // Your application creates a new, empty MessageSet object which is passed 
    // in the last argument and filled upon success.

    // The following properties are used instead of function arguments.
    imap.sortCriteria = "DATE SUBJECT"
    imap.searchCharset = "UTF-8"

    let mset = CkoMessageSet()!
    success = imap.queryMbx(criteria: searchCriteria, bUid: bUid, msgSet: mset)
    if success == false {
        print("\(imap.lastErrorText!)")
        return
    }


}