# cp.plist.archiver

Supports 'defrosting' a table which is made up from an 'NSKeyArchiver' record.


# API Overview

Functions - API calls offered directly by the extension

  • isPlist
  • unarchive
  • unarchiveBase64
  • unarchiveFile

# API Documentation

# Functions

# isPlist

Signature cp.plist.archiver.isPlist(data) -> boolean
Type Function
Description Checks if the given data is a supported plist.
Parameters
  • data - The data to check.
Returns
  • true if the data is a supported plist, false otherwise.
Notes None
Examples None
Source src/extensions/cp/plist/archiver.lua line 162

# unarchive

Signature cp.plist.archiver.unarchive(archive, defrostFn) -> table | nil, string
Type Function
Description Unarchives a LUA table which was archived into a plist using the NSKeyedArchiver.
Parameters
  • archive - the table containing the archive plist as a table
  • defrostFn - (optional) a function which will be passed an object with a '$class' entry
Returns
  • The unarchived plist table
Notes
  • A 'defrost' function can be provided, which will be called whenever a table with a '$class'
  • structure is present. It will receive the table and the classname and should either return a modified value
  • if the class was handled, or nil if it was unable to handle the class. Eg:
  • </li><li> local result = archiver.unarchive(archiveData, function(frozen, classname)</li><li> if classname == "XXMyClass" then</li><li> return MyClass:new(frozen.foo, frozen.bar)</li><li> end</li><li> return nil</li><li> end)</li><li>
Examples None
Source src/extensions/cp/plist/archiver.lua line 173

# unarchiveBase64

Signature cp.plist.archiver.unarchiveBase64(base64data, defrostFn) -> table | nil, string
Type Function
Description Unarchives a Base64 encoded string which was archived into a plist using the NSKeyedArchiver.
Parameters
  • base64data - the file containing the archive plist
  • defrostFn - (optional) a function which will be passed an object with a '$class' entry
Returns
  • The unarchived plist.
Notes
  • A 'defrost' function can be provided, which will be called whenever a table with a '$class'
  • structure is present. It will receive the table and the classname and should either return a modified value
  • if the class was handled, or nil if it was unable to handle the class. Eg:
  • </li><li> local result = archiver.unarchiveFile(filename, function(frozen, classname)</li><li> if classname == "XXMyClass" then</li><li> return MyClass:new(frozen.foo, frozen.bar)</li><li> end</li><li> return nil</li><li> end)</li><li>
Examples None
Source src/extensions/cp/plist/archiver.lua line 210

# unarchiveFile

Signature cp.plist.archiver.unarchiveFile(filename, defrostFn) -> table | nil, string
Type Function
Description Unarchives a plist file which was archived into a plist using the NSKeyedArchiver.
Parameters
  • filename - the file containing the archive plist
  • defrostFn - (optional) a function which will be passed an object with a '$class' entry
Returns
  • The unarchived plist.
Notes
  • A 'defrost' function can be provided, which will be called whenever a table with a '$class'
  • structure is present. It will receive the table and the classname and should either return a modified value
  • if the class was handled, or nil if it was unable to handle the class. Eg:
  • </li><li> local result = archiver.unarchiveFile(filename, function(frozen, classname)</li><li> if classname == "XXMyClass" then</li><li> return MyClass:new(frozen.foo, frozen.bar)</li><li> end</li><li> return nil</li><li> end)</li><li>
Examples None
Source src/extensions/cp/plist/archiver.lua line 243