Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSKeyedArchiverMBS class.

NSKeyedArchiverMBS.archiverData as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the archived data.

NSKeyedArchiverMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the receiver, initialized for encoding an archive.

See also:

NSKeyedArchiverMBS.Constructor(RequiringSecureCoding as Boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 21.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an archiver to encode data, and optionally disables secure coding.
Example
Dim ckRecord As New CKRecordMBS("MyType")

// archive
Dim coder As NSKeyedArchiverMBS = New NSKeyedArchiverMBS(True)
ckRecord.encodeSystemFieldsWithCoder(coder)
coder.finishEncoding()

Dim encodedRecordValue As String = coder.archiverData

// unarchive
Dim unarchiver As New NSKeyedUnarchiverMBS(encodedRecordValue)
Dim decodedRecord As CKRecordMBS = New CKRecordMBS(unarchiver)

MsgBox "OK "+decodedRecord.recordType

Exception n As NSExceptionMBS
MsgBox n.message

requiresSecureCoding: A Boolean value indicating whether all encoded objects must conform to NSSecureCoding.

To prevent the possibility of encoding an object that NSKeyedUnarchiver can’t decode, set requiresSecureCoding to true whenever possible. This ensures that all encoded objects conform to NSSecureCoding.

Requires macOS 10.13.

See also:

NSKeyedArchiverMBS.finishEncoding

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Instructs the receiver to construct the final data stream.

No more values can be encoded after this method is called. You must call this method when finished.

NSKeyedArchiverMBS.outputFormat as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa MBS MacBase Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets or queries the format in which the receiver encodes its data.
Example
// make archiver
dim a as new NSKeyedArchiverMBS
a.outputFormat = a.kCFPropertyListXMLFormat_v1_0

// add a string
a.encodeString "Hello World", "Greeting"

// finish
a.finishEncoding

// query data and show
dim m as MemoryBlock = a.archiverData
dim s as string = DefineEncoding(m, encodings.UTF8)
MsgBox s

(Read and Write computed property)

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...