ArchiveCoder

public class ArchiveCoder : NSObject, NSSecureCoding

AnyArchivable归档编码器,注意当archiveObject为struct时,必须先调用registerType注册

Static

  • 是否是有效的AnyArchivable归档对象或对象数组

    Declaration

    Swift

    public static func isArchivableObject(_ object: Any?) -> Bool
  • 是否是有效的AnyArchivable归档数据(即ArchiveCoder归档数据)

    Declaration

    Swift

    public static func isArchivableData(_ data: Data?) -> Bool
  • 将AnyArchivable对象编码为Data数据,不调用NSKeyedArchiver

    Declaration

    Swift

    public static func encodeObject(_ object: AnyArchivable?) -> Data?
  • 将AnyArchivable对象数组编码为Data数据,不调用NSKeyedArchiver

    Declaration

    Swift

    public static func encodeObjects(_ objects: [AnyArchivable]?) -> Data?
  • 将Data数据解码为AnyArchivable对象,不调用NSKeyedUnarchiver

    Declaration

    Swift

    public static func decodeObject<T>(_ data: Data?, as type: T.Type = T.self) -> T? where T : AnyArchivable
  • 将Data数据解码为AnyArchivable对象数组,不调用NSKeyedUnarchiver

    Declaration

    Swift

    public static func decodeObjects<T>(_ data: Data?, as type: T.Type = T.self) -> [T]? where T : AnyArchivable
  • 注册struct归档类型,如果为class则无需注册(NSClassFromString自动处理)

    Declaration

    Swift

    public static func registerType<T>(_ type: T.Type) where T : AnyArchivable
  • 归档类型加载器,加载未注册类型时会尝试调用并注册,block返回值为registerType方法type参数

    Declaration

    Swift

    public static let sharedLoader: Loader<String, any AnyArchivable.Type>

Accessor

  • 指定AnyArchivable对象或对象数组,自动处理归档数据

    Declaration

    Swift

    public var archivableObject: Any? { get set }
  • 归档数据,设置归档对象时自动处理

    Declaration

    Swift

    public private(set) var archiveData: Data? { get }
  • 归档类型,如果归档对象为struct时,必须先调用registerType注册

    Declaration

    Swift

    public private(set) var archiveType: String? { get }
  • Undocumented

    Declaration

    Swift

    override public init()

NSSecureCoding

  • Undocumented

    Declaration

    Swift

    public static var supportsSecureCoding: Bool { get }
  • Undocumented

    Declaration

    Swift

    public required init?(coder: NSCoder)
  • Undocumented

    Declaration

    Swift

    public func encode(with coder: NSCoder)