Super class: NSCoderMBS
|Type||Topic||Plugin||Version||macOS||Windows||Linux||Console & Web||iOS|
|class||Cocoa||MBS MacBase Plugin||13.2||Yes||No||No||Yes, macOS only||No|
// make archiver
dim a as new NSKeyedArchiverMBS
// add a string
a.encodeString "Hello World", "Greeting"
// query data
dim m as MemoryBlock = a.archiverData
// start unarchiver
dim u as new NSKeyedUnarchiverMBS(m)
// query and display a value
dim s as string = u.decodeString("Greeting")
NSKeyedUnarchiver, a concrete subclass of NSCoder, defines methods for decoding a set of named objects (and scalar values) from a keyed archive. Such archives are produced by instances of the NSKeyedArchiver class.
A keyed archive is encoded as a hierarchy of objects. Each object in the hierarchy serves as a namespace into which other objects are encoded. The objects available for decoding are restricted to those that were encoded within the immediate scope of a particular object. Objects encoded elsewhere in the hierarchy, whether higher than, lower than, or parallel to this particular object, are not accessible. In this way, the keys used by a particular object to encode its instance variables need to be unique only within the scope of that object.
If you invoke one of the decode... methods of this class using a key that does not exist in the archive, a non-positive value is returned. This value varies by decoded type. For example, if a key does not exist in an archive, decodeBoolForKey returns false, decodeIntForKey returns 0, and decodeObjectForKey returns nil.
NSKeyedUnarchiver supports limited type coercion. A value encoded as any type of integer, whether a standard int or an explicit 32-bit or 64-bit integer, can be decoded using any of the integer decode methods. Likewise, a value encoded as a float or double can be decoded as either a float or a double value. If an encoded value is too large to fit within the coerced type, the decoding method raises an NSRangeException. Further, when trying to coerce a value to an incompatible type, for example decoding an int as a float, the decoding method raises an NSInvalidUnarchiveOperationException.
Subclass of the NSCoderMBS class.
Super class NSCoderMBS
- property Handle as Integer
- 32 methods
- method allowsKeyedCoding as boolean
- method Constructor
- method containsValueForKey(key as string) as boolean
- method decodeBool(key as string) as boolean
- method decodeBytes(key as string) as MemoryBlock
- method decodeCFObjectMBS(key as string) as Variant
- method decodeDictionary(key as string) as Dictionary
- method decodeDouble(key as string) as Double
- method decodeFloat(key as string) as single
- method decodeInt32(key as string) as Int32
- method decodeInt64(key as string) as Int64
- method decodeNSURLFile(key as string) as folderitem
- method decodeNSURLString(key as string) as String
- method decodePoint(key as string) as NSPointMBS
- method decodeRect(key as string) as NSRectMBS
- method decodeSize(key as string) as NSSizeMBS
- method decodeString(key as string) as string
- method encodeBool(value as boolean, key as string)
- method encodeBytes(value as MemoryBlock, key as string)
- method encodeCFObjectMBS(value as Variant, key as string)
- method encodeDictionary(value as Dictionary, key as string)
- method encodeDouble(value as Double, key as string)
- method encodeFloat(value as single, key as string)
- method encodeInt32(value as Int32, key as string)
- method encodeInt64(value as Int64, key as string)
- method encodeNSURLFile(value as folderitem, key as string)
- method encodeNSURLString(value as String, key as string)
- method encodePoint(value as NSPointMBS, key as string)
- method encodeRect(value as NSRectMBS, key as string)
- method encodeSize(value as NSSizeMBS, key as string)
- method encodeString(value as string, key as string)
- method systemVersion as Integer
This class has no sub classes.
The items on this page are in the following plugins: MBS MacBase Plugin.
MBS Xojo blog