Classes

The following classes are available globally.

  • Holds all of the schema information about a table schema’s columns as read from a backing data store.

    See more

    Declaration

    Swift

    open class ADColumnSchema
  • Decodes a Codable or Decodable class from a ADRecord read from a SQLite database using a ADSQLiteProvider. The result is an instance of the class with the properties set from the database record. This decoder will automatically handle URLs and Enums (if the Enum is value based and also marked Codable or Decodable).

    Example:

    import ActionUtilities
    import ActionData
    
    class Category: ADDataTable {
    
        enum CategoryType: String, Codable {
            case local
            case web
        }
    
        static var tableName = "Categories"
        static var primaryKey = "id"
        static var primaryKeyType: ADDataTableKeyType = .computedInt
    
        var id = 0
        var added = Date()
        var name = ""
        var description = ""
        var enabled = true
        var highlightColor = UIColor.white.toHex()
        var type: CategoryType = .local
        var icon: Data = UIImage().toData()
    
        required init() {
    
        }
    }
    
    let encoder = ADSQLEncoder()
    let category = Category()
    let data = try encoder.encode(category)
    
    let decoder = ADSQLDecoder()
    let category2 = try decoder.decode(Category.self, from: data)
    

    Remark

    To retrieve UIColors in the record use the String.uiColor extension property and to retrieve UIImages use the String.uiImage extension property.
    See more

    Declaration

    Swift

    public class ADSQLDecoder: Decoder
  • Holds all the information about a table’s schema as read from a backing data store.

    See more

    Declaration

    Swift

    open class ADTableSchema
  • Encodes a Codable or Encodable class into a ADRecord that can be written into a SPON database using a ADSPONiteProvider. The result is a dictionary of key/value pairs representing the data currently stored in the class. This encoder will automatically handle URLs and Enums (if the Enum is value based and also marked Codable or Encodable).

    Example:

    import ActionUtilities
    import ActionData
    
    class Category: ADDataTable {
    
        enum CategoryType: String, Codable {
            case local
            case web
        }
    
        static var tableName = "Categories"
        static var primaryKey = "id"
        static var primaryKeyType: ADDataTableKeyType = .computedInt
    
        var id = 0
        var added = Date()
        var name = ""
        var description = ""
        var enabled = true
        var highlightColor = UIColor.white.toHex()
        var type: CategoryType = .local
        var icon: Data = UIImage().toData()
    
        required init() {
    
        }
    }
    
    let encoder = ADSPONEncoder()
    let category = Category()
    let data = try encoder.encode(category)
    

    Remark

    To store UIColors in the record use the toHex() extension method and to store UIImages use the toData() extension method.
    See more

    Declaration

    Swift

    public class ADSPONEncoder: Encoder
  • Decodes a Codable or Decodable class from a ADRecord read from a SQLite database using a ADSPONiteProvider. The result is an instance of the class with the properties set from the database record. This decoder will automatically handle URLs and Enums (if the Enum is value based and also marked Codable or Decodable).

    Example:

    import ActionUtilities
    import ActionData
    
    class Category: ADDataTable {
    
        enum CategoryType: String, Codable {
            case local
            case web
        }
    
        static var tableName = "Categories"
        static var primaryKey = "id"
        static var primaryKeyType: ADDataTableKeyType = .computedInt
    
        var id = 0
        var added = Date()
        var name = ""
        var description = ""
        var enabled = true
        var highlightColor = UIColor.white.toHex()
        var type: CategoryType = .local
        var icon: Data = UIImage().toData()
    
        required init() {
    
        }
    }
    
    let encoder = ADSPONEncoder()
    let category = Category()
    let data = try encoder.encode(category)
    
    let decoder = ADSPONDecoder()
    let category2 = try decoder.decode(Category.self, from: data)
    

    Remark

    To retrieve UIColors in the record use the String.uiColor extension property and to retrieve UIImages use the String.uiImage extension property.
    See more

    Declaration

    Swift

    public class ADSPONDecoder: Decoder
  • Represents an in-memory Data Store used to provide SQL ability to data sources that typically do not support SQL (such as JSON or XML). ADDataStore works with ADTableStore to define both the structure of the tables and to contain the rows of data stored in each table. ADDataStore understands a subset of the full SQL instruction set (as known by SQLite).

    Use the execute method to execute non-query SQL statements against the Data Store. For example:

    let datastore = ADDataStore()
    
    var sql = """
    CREATE TABLE IF NOT EXISTS parts
    (
        part_id           INTEGER   PRIMARY KEY AUTOINCREMENT,
        stock             INTEGER   DEFAULT 0   NOT NULL,
        name              TEXT,
        description       TEXT      CHECK( description != '' ),    -- empty strings not allowed
        available         BOOL      DEFAULT true
    );
    """
    
    try datastore.execute(sql)
    

    Use the query method to execute query SQL statements and return rows matching the result. For example:

    let results = try datastore.query("SELECT * FROM parts")
    print(results)
    

    Remark

    Since a ADDataStore holds all data in-memory, care should be taken not to overload memory. As a result, an ADDataStore is not a good choice for working with large amounts of data.
    See more

    Declaration

    Swift

    public class ADDataStore
  • Defines a set of utilities to handle data related issues such as comparing two values of type Any.

    See more

    Declaration

    Swift

    public class ADUtilities
  • Encodes a Codable or Encodable class into a ADRecord that can be written into a SQLite database using a ADSQLiteProvider. The result is a dictionary of key/value pairs representing the data currently stored in the class. This encoder will automatically handle URLs and Enums (if the Enum is value based and also marked Codable or Encodable).

    Example:

    import ActionUtilities
    import ActionData
    
    class Category: ADDataTable {
    
        enum CategoryType: String, Codable {
            case local
            case web
        }
    
        static var tableName = "Categories"
        static var primaryKey = "id"
        static var primaryKeyType: ADDataTableKeyType = .computedInt
    
        var id = 0
        var added = Date()
        var name = ""
        var description = ""
        var enabled = true
        var highlightColor = UIColor.white.toHex()
        var type: CategoryType = .local
        var icon: Data = UIImage().toData()
    
        required init() {
    
        }
    }
    
    let encoder = ADSQLEncoder()
    let category = Category()
    let data = try encoder.encode(category)
    

    Remark

    To store UIColors in the record use the toHex() extension method and to store UIImages use the toData() extension method.
    See more

    Declaration

    Swift

    public class ADSQLEncoder: Encoder
  • Defines a passable dictionary of ADRecord values when encoding or decoding an Action Data class instance. ADInstanceDictionary also introduces support for the new Swift Portable Object Notation (SPON) data format that allows complex data models to be encoded in a portable text string that encodes not only property keys and data, but also includes type information about the encoded data. For example:

    Example:

    let data = "@obj:Rectangle<left!=`0` bottom!=`0` right!=`0` top!=`0`>"
    let dictionary = ADInstanceDictionary.decode(data)
    

    The portable, human-readable string format encodes values with a single character type designator as follows:

    • % - Bool
    • ! - Int
    • $ - String
    • ^ - Float
    • & - Double
    • * - Embedded NSData or Data value

    Additionally, embedded arrays will be in the @array[...] format and embedded dictionaries in the @obj:type<...> format.

    See more

    Declaration

    Swift

    public class ADInstanceDictionary
  • The ADSPONProvider provides both light-weight, low-level access to data stored in a Swift Portable Object Notation (SPON) database and high-level access via a Object Relationship Management (ORM) model. Use provided functions to read and write data stored in a ADRecord format from and to the database using SQL statements directly.

    Example:

    let provider = ADSPONProvider.shared
    let record = try provider.query("SELECT * FROM Categories WHERE id = ?", withParameters: [1])
    print(record["name"])
    

    Optionally, pass a class instance conforming to the ADDataTable protocol to the ADSPONProvider and it will automatically handle reading, writing and deleting data as required.

    Example:

    let addr1 = Address(addr1: "PO Box 1234", addr2: "", city: "Houston", state: "TX", zip: "77012")
    let addr2 = Address(addr1: "25 Nasa Rd 1", addr2: "Apt #123", city: "Seabrook", state: "TX", zip: "77586")
    
    let p1 = Person(firstName: "John", lastName: "Doe", addresses: ["home":addr1, "work":addr2])
    let p2 = Person(firstName: "Sue", lastName: "Smith", addresses: ["home":addr1, "work":addr2])
    
    let group = Group(name: "Employees", people: [p1, p2])
    try provider.save(group)
    

    Remark

    The ADSPONProvider will automatically create a SQL Table from a class instance if one does not already exist. In addition, ADSPONProvider contains routines to preregister or update the schema classes conforming to the ADDataTable protocol which will build or modify the database tables as required.
    See more

    Declaration

    Swift

    open class ADSPONProvider: ADDataProvider
  • Holds the source table or table group for a SQL SELECT statement. If the type is none this is a single table name and not a join between two (or more) tables.

    See more

    Declaration

    Swift

    public class ADSQLJoinClause
  • Defines a passable array of values used as temporary storage when encoding or decoding an Action Data class. ADInstanceArray also introduces support for the new Swift Portable Object Notation (SPON) data format that allows complex data models to be encoded in a portable text string that encodes not only property keys and data, but also includes type information about the encoded data. For example:

    Example:

    let data = "@array[1!, 2!, 3!, 4!]"
    let array = ADInstanceArray.decode(data)
    

    The portable, human-readable string format encodes values with a single character type designator as follows:

    • % - Bool
    • ! - Int
    • $ - String
    • ^ - Float
    • & - Double
    • * - Embedded NSData or Data value

    Additionally, embedded arrays will be in the @array[...] format and embedded dictionaries in the @obj:type<...> format.

    See more

    Declaration

    Swift

    public class ADInstanceArray
  • The Appracatappra License Manager handles verfiying your licensed version of a Appracatappra developer product purchased from our online store. You will need to provide the customer information used to purchase the product, the product license that was sent to you in your purchase receipt and a product activation key. You can generate the activation key at the Activate License page of the Appracatappra, LLC. website. You have a limited number of product activations so please make a copy of your Activation Key and keep it in a safe place.

    Typically, you will provide this information to the AppracatappraLicenseManager when the app first starts in the main method of the Main.cs file.

    Failure to include the requested information will result in a Toast style popup being displayed that reads, Unlicensed Appracatappra Product whenever an Action Component is used.

    See more

    Declaration

    Swift

    public class AppracatappraLicenseManager
  • Defines a binary operation being performed on two expressions in a SQL instruction such as adding two values or comparing two values to see if they are equal.

    See more

    Declaration

    Swift

    public class ADSQLBinaryExpression: ADSQLExpression
  • The ADSQLiteProvider provides both light-weight, low-level access to data stored in a SQLite database and high-level access via a Object Relationship Management (ORM) model. Use provided functions to read and write data stored in a ADRecord format from and to the database using SQL statements directly.

    Example:

    let provider = ADSQLiteProvider.shared
    let record = try provider.query("SELECT * FROM Categories WHERE id = ?", withParameters: [1])
    print(record["name"])
    

    Optionally, pass a class instance conforming to the ADDataTable protocol to the ADSQLiteProvider and it will automatically handle reading, writing and deleting data as required.

    Example:

    let addr1 = Address(addr1: "PO Box 1234", addr2: "", city: "Houston", state: "TX", zip: "77012")
    let addr2 = Address(addr1: "25 Nasa Rd 1", addr2: "Apt #123", city: "Seabrook", state: "TX", zip: "77586")
    
    let p1 = Person(firstName: "John", lastName: "Doe", addresses: ["home":addr1, "work":addr2])
    let p2 = Person(firstName: "Sue", lastName: "Smith", addresses: ["home":addr1, "work":addr2])
    
    let group = Group(name: "Employees", people: [p1, p2])
    try provider.save(group)
    

    Remark

    The ADSQLiteProvider will automatically create a SQL Table from a class instance if one does not already exist. In addition, ADSQLiteProvider contains routines to preregister or update the schema classes conforming to the ADDataTable protocol which will build or modify the database tables as required.
    See more

    Declaration

    Swift

    open class ADSQLiteProvider: ADDataProvider
  • Parses a SQL statement into an Action Data SQL Document Object Model (DOM). This parser currently supports a subset of SQL commands as defined by SQLite. for example:

    let sql = """
    CREATE TABLE IF NOT EXISTS parts
    (
        part_id           INTEGER   PRIMARY KEY,
        stock             INTEGER   DEFAULT 0   NOT NULL,
        description       TEXT      CHECK( description != '' )    -- empty strings not allowed
    );
    """
    
    let instructions = try ADSQLParser.parse(sql)
    print(instructions)
    
    See more

    Declaration

    Swift

    public class ADSQLParser
  • Represents an in-memory SQL Data Store table used to hold both the table’s schema and the data it represents.

    Remark

    Since a ADTableStore holds all data in-memory, care should be taken not to overload memory. As a result, an ADTableStore is not a good choice for working with large amounts of data.
    See more

    Declaration

    Swift

    public class ADTableStore