outputFormat
The format in which the receiver encodes its data.
var outputFormat: PropertyListSerialization.PropertyListFormat { get set }
The available formats are xml
and binary
.
The format in which the receiver encodes its data.
var outputFormat: PropertyListSerialization.PropertyListFormat { get set }
s10Foundation15NSKeyedArchiverC12outputFormat0A10Essentials19PropertyListDecoderC0ghE0Ovp
What are these?BD5Y
The available formats are xml
and binary
.
import Foundation
class NSKeyedArchiver
NSKeyedArchiver
, a concrete subclass of NSCoder
, provides a way to encode objects (and scalar values) into an architecture-independent format that can be stored in a file. When you archive a set of objects, the class information and instance variables for each object are written to the archive. NSKeyedArchiver
’s companion class, NSKeyedUnarchiver
, decodes the data in an archive and creates a set of objects equivalent to the original set.
class PropertyListSerialization
typealias PropertyListFormat = PropertyListDecoder.PropertyListFormat
convenience init(requiringSecureCoding: Bool)
class func archivedData(withRootObject object: Any, requiringSecureCoding: Bool) throws -> Data
class func classNameForClass(_ cls: AnyClass) -> String?
Returns the class name with which NSKeyedArchiver
encodes instances of a given class.
class func setClassName(_ codedName: String?, for cls: AnyClass)
Adds a class translation mapping to NSKeyedArchiver
whereby instances of a given class are encoded with a given class name instead of their real class names.
override var allowsKeyedCoding: Bool { get }
weak var delegate: (any NSKeyedArchiverDelegate)?
The archiver’s delegate.
var encodedData: Data { get }
Returns the encoded data for the archiver.
override var error: (any Error)? { get set }
override var requiresSecureCoding: Bool { get set }
Indicates whether the archiver requires all archived classes to conform to NSSecureCoding
.
override var systemVersion: UInt32 { get }
func classNameForClass(_ cls: AnyClass) -> String?
Returns the class name with which the archiver encodes instances of a given class.
override func encode(_ data: Data)
override func encode(_ object: Any?)
override func encode(_ boolv: Bool, forKey key: String)
Encodes a given Boolean value and associates it with a given key.
override func encode(_ realv: Double, forKey key: String)
Encodes a given double value and associates it with a given key.
override func encode(_ realv: Float, forKey key: String)
Encodes a given float value and associates it with a given key.
override func encode(_ intv: Int, forKey key: String)
Encodes a given integer value and associates it with a given key.
override func encode(_ intv: Int32, forKey key: String)
Encodes a given 32-bit integer value and associates it with a given key.
override func encode(_ intv: Int64, forKey key: String)
Encodes a given 64-bit integer value and associates it with a given key.
override func encode(_ objv: Any?, forKey key: String)
Encodes a given object and associates it with a given key.
override func encodeBytes(_ bytesp: UnsafePointer<UInt8>?, length lenv: Int, forKey key: String)
Encodes a given number of bytes from a given C array of bytes and associates them with the a given key.
override func encodeConditionalObject(_ object: Any?)
override func encodeConditionalObject(_ objv: Any?, forKey key: String)
Encodes a reference to a given object and associates it with a given key only if it has been unconditionally encoded elsewhere in the archive with encode(_:forKey:)
.
override func encodePropertyList(_ aPropertyList: Any)
func encodePropertyList(_ aPropertyList: Any, forKey key: String)
override func encodeValue(ofObjCType typep: UnsafePointer<Int8>, at addr: UnsafeRawPointer)
func finishEncoding()
Instructs the archiver to construct the final data stream.
func setClassName(_ codedName: String?, for cls: AnyClass)
Adds a class translation mapping to NSKeyedArchiver
whereby instances of a given class are encoded with a given class name instead of their real class names.
override convenience init()
convenience init(forWritingWith data: NSMutableData)
Returns the archiver, initialized for encoding an archive into a given a mutable-data object.
class func archiveRootObject(_ rootObject: Any, toFile path: String) -> Bool
Archives an object graph rooted at a given object by encoding it into a data object then atomically writes the resulting data object to a file at a given path, and returns a Boolean value that indicates whether the operation was successful.
class func archivedData(withRootObject rootObject: Any) -> Data
Returns an NSData
object containing the encoded form of the object graph whose root object is given.