ZTPlist
Property list, A file with the default settings.
In the macOS, iOS, NeXTSTEP, and GNUstep programming frameworks, property list files are files that store serialized objects.
Property list files use the filename extension .plist, and thus are often referred to as p-list files.
let plist = ZTPlist(withNameAtDocumentDirectory: "Plister")
plist.set(2020,for: "new.year")
plist.get("new.year")
// Output: 2020
-
Default folder name which stores plist. you can change it
-
Url of plist wether inside a bundle or document directory
-
Return result of encryption object, if encryption was
nil
result will be false -
An AES object that used to encrypt and decrypt properties value
-
Lazy initialized copy of
dicitonary
property which can be used to read and write at last onwillTerminateNotification
anddidEnterBackgroundNotification
cache will write to document directory anddictionary
property will updated. -
Property list size with byte described
-
Property list size including Binary prefix
-
Property list file name
-
Property list name
-
Write dictionary to document directory, no need to call this method ZTPlist will do it when needed.
-
Initialize a plist object with given url inside main bundle.
every file inside a bundle is read-only so you can only read object attributes.
let url = Bundle.main.url(forResource: "Info", withExtension: "plist") let plist = ZTPlist(mainBundleUrl: url!)
-
Initialize a plist object with given name and store plist file inside document directory then you can read and write.
If there is a plist which has same name this method only retrive that plist without any change to that file.
let name = "Client" let plist = ZTPlist(withNameAtDocumentDirectory: name)
-
Initialize a encrypted value plist object with given name and store plist file inside document directory then you can read and write. If there is a plist which has same name this method only retrive that plist without any change to that file.
let name = "Wallet" let plist = ZTPlist(withNameAtDocumentDirectory: name)
-
Delete given plist from DocumentDirectory and Deinitialize the object at same time.
let settings = ZTPlist(withNameAtDocumentDirectory: "Settings") ZTPlist.delete(&settings) ZTLogger.instance.ztDebugPrint("Settings: \(settings)") // Settings: nil
-
Encrypt given value and returns encrypted data
Takes any argument and convert to String then create a Data object from string, encoding in utf8 and encrypt encoded utf8 to plist encryption algorithm
-
Decrypt given encrypted data and returns decrypted data
-
Translate given decrypted data in most accurate performance and returns a Dictionary
-
Translate given decrypted data in most accurate performance and returns a Collection
-
Translate given decrypted data in most accurate performance and returns a String
-
Translate given decrypted data in most accurate performance and returns a Bool
-
Translate given decrypted data in most accurate performance and returns a Int
-
Translate given decrypted data in most accurate performance and returns a Float
-
Translate given decrypted data in most accurate performance and returns a Double
-
Translate given decrypted data in most accurate performance and returns a Date
-
A type representing an error value that wont thrown but raise in debugger
See moreDeclaration
Swift
-
Return cached plist as a collection of key value pairs
-
Sets the value of the specified key to the specified value.
If plist encryption enabled, rawValue will encrypted with AES algorithm. and save to plist for given key.
let plist = ZTPlist(withNameAtDocumentDirectory: "Information") let key = "didUserSignedIn" plist.set(true, for: key) // Sets true value for didUserSignedIn key plist.get(key) // result will be true
-
Returns the value for the property identified by a given key.
If plist encryption enabled, value for given key is represented as decrypted Data that contains String, for better get use default methods to get value as bool,int,string,float,double,json,collection.
-
Overwrite a clean dictionary at plist url
-
Remove given tuple keys from plist
-
Remove given collection keys from plist
-
Returns Bool value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted and translate to Bool type with most accurate performance.
-
Returns Int value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted and translate to Int type with most accurate performance.
-
Returns Double value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted and translate to Double type with most accurate performance.
-
Returns Float value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted and translate to Float type with most accurate performance.
-
Returns String value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted and translate to String type with most accurate performance.
-
Returns Dictionary value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted and translate to Dictionary type with most accurate performance.
-
Returns Collection value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted and translate to Collection type with most accurate performance.
-
Returns Date value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted in TimeInterval format and translate to Date type with most accurate performance.
-
Returns Data value for the property identified by a given key.
Encryption
If plist encryption enabled, the result will decrypted in TimeInterval format and translate to Date type with most accurate performance.
-
Remove value for given key.