ADInstanceDictionary
public class ADInstanceDictionary
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*
- EmbeddedNSData
orData
value
Additionally, embedded arrays will be in the @array[...]
format and embedded dictionaries in the @obj:type<...>
format.
-
Converts a given value into a format that can be safely stored in an
ADInstanceDictionary
portable, human-readable string format.Declaration
Swift
public static func escapeValue(_ value: String) -> String
Parameters
value
The string value to be escaped.
Return Value
The string with any non-safe characters encoded in a safe format.
-
Converts a value stored in portable, human-readable string format and converts it back to its original format.
Declaration
Swift
public static func unescapeValue(_ value: String) -> String
Parameters
value
The string including any escaped values.
Return Value
The string with any escaped values converted back to their original format
-
Takes a
ADInstanceDictionary
object stored in a portable, human-readable string format and converts it to a dictionary of the original values.Example:
let data = "@obj:Rectangle<left!=`0` bottom!=`0` right!=`0` top!=`0`>" let dictionary = ADInstanceDictionary.decode(data)
Data Types
The portable, human-readable string format encodes values with a single character type designator as follows:
%
- Bool!
- Int$
- String^
- Float&
- Double*
-NSData
orData
as a base 64 encoded string
Additionally, embedded arrays (
ADInstanceArray
) will be in the@array[...]
format and embedded dictionaries (ADInstanceDictionary
) in the@obj:type<...>
format.Declaration
Swift
public static func decode(_ text: String) -> ADInstanceDictionary
Parameters
text
The string in the portable, human-readable string format.
Return Value
An instance dictionary of the original Swift object values.
-
Stores the name a sub
ADDataTable
used in a one-to-one foreign key relationship with the main table.Declaration
Swift
public var subTableName: String = ""
-
Stores the name of the primary key for a sub
ADDataTable
used in a one-to-one foreign key relationship with the main table.Declaration
Swift
public var subTablePrimaryKey: String = ""
-
Stores the primary key type for a sub
ADDataTable
used in a one-to-one foreign key relationship with the main table.Declaration
Swift
public var subTablePrimaryKeyType: ADDataTableKeyType = .uniqueValue
-
The name of the type of object being encoded in the dictionary
Declaration
Swift
public var typeName: String = ""
-
Converts the
ADInstanceDictionary
instance to a portable, human-readable string format.Data Types
The portable, human-readable string format encodes values with a single character type designator as follows:
%
- Bool!
- Int- ` - String
^
- Float&
- Double
Additionally, embedded arrays will be in the
@array[...]
format and embedded dictionaries (ADInstanceDictionary
) in the@obj:type<...>
format.Example Output
@obj:Appearance<borderWidth!=`1` fillColor$=`#FFFFFF` textColor$=`#FFFFFF` borderColor$=`#FFFFFF` hasBorder%=`true` placement=@obj:Rectangle<left!=`0` bottom!=`0` right!=`0` top!=`0`>>
Declaration
Swift
public func encode() -> String
Return Value
A portable, human-readable string representing the dictionary of values.