Instance Method

encodeConditionalObject(_:)

An encoding method for subclasses to override to conditionally encode an object, preserving common references to it.

Declaration

func encodeConditionalObject(_ object: Any?)

Discussion

In the overriding method, object should be encoded only if it’s unconditionally encoded elsewhere (with any other encode...Object: method).

This method must be matched by a subsequent decodeObject() message. Upon decoding, if object was never encoded unconditionally, decodeObject returns nil in place of object. However, if object was encoded unconditionally, all references to object must be resolved.

NSCoder’s implementation simply invokes encode(_:).

See Also

Encoding General Data

func encodeArray(ofObjCType: UnsafePointer<Int8>, count: Int, at: UnsafeRawPointer)

Encodes an array of the given Objective-C type, provided the number of items and a pointer.

func encode(Bool, forKey: String)

Encodes a Boolean value and associates it with the string key.

func encodeBycopyObject(Any?)

An encoding method for subclasses to override such that it creates a copy, rather than a proxy, when decoded.

func encodeByrefObject(Any?)

An encoding method for subclasses to override such that it creates a proxy, rather than a copy, when decoded.

func encodeBytes(UnsafeRawPointer?, length: Int)

Encodes a buffer of data of an unspecified type.

func encodeBytes(UnsafePointer<UInt8>?, length: Int, forKey: String)

Encodes a buffer of data, given its length and a pointer, and associates it with a string key.

func encodeConditionalObject(Any?, forKey: String)

An encoding method for subclasses to override to conditionally encode an object, preserving common references to it, only if it has been unconditionally encoded.

func encode(Data)

Encodes a given data object.

func encode(Double, forKey: String)

Encodes a double-precision floating point value and associates it with the string key.

func encode(Float, forKey: String)

Encodes a floating point value and associates it with the string key.

func encodeCInt(Int32, forKey: String)

Encodes a C integer value and associates it with the string key.

func encode(Int, forKey: String)

Encodes an integer value and associates it with the string key.

func encode(Int32, forKey: String)

Encodes a 32-bit integer value and associates it with the string key.

func encode(Int64, forKey: String)

Encodes a 64-bit integer value and associates it with the string key.

func encode(Any?)

Encodes an object.

func encode(Any?, forKey: String)

Encodes an object and associates it with the string key.

func encode(NSPoint)

Encodes a point.

func encode(NSPoint, forKey: String)

Encodes a point and associates it with the string key.

func encodePropertyList(Any)

Encodes a property list.

func encode(NSRect)

Encodes a rectangle structure.

func encode(NSRect, forKey: String)

Encodes a rectangle structure and associates it with the string key.

func encodeRootObject(Any)

An encoding method for subclasses to override to encode an interconnected group of objects, starting with the provided root object.

func encode(NSSize)

Encodes a size structure.

func encode(NSSize, forKey: String)

Encodes a size structure and associates it with the given string key.

func encodeValue(ofObjCType: UnsafePointer<Int8>, at: UnsafeRawPointer)

Encodes a value of the given type at the given address.