API参考Foundation

NSKeyedArchiver

对象归档(对象→NSData/文件)。

NSKeyedArchiver 用于把对象图归档为二进制数据(NSData)或写入文件。

类成员 (Class members)

archivedDataWithRootObject

将根对象归档为 NSData。

static archivedDataWithRootObject(rootObject: any): NSData

Parameters:

NameTypeDescription
rootObjectany根对象(需支持 NSCoding)。

Return Value:

  • NSData: 归档数据。

archiveRootObjectToFile

将根对象归档到文件。

static archiveRootObjectToFile(rootObject: any, path: string): boolean

Parameters:

NameTypeDescription
rootObjectany根对象。
pathstring文件路径。

Return Value:

  • boolean: 是否成功。

setClassNameForClass

设置类名映射(归档用)。

static setClassNameForClass(codedName: string, cls: any): void

Parameters:

NameTypeDescription
codedNamestring归档中的类名。
clsany实际类。

Return Value:

  • 无。

classNameForClass

取类的归档名。

static classNameForClass(cls: any): string

Parameters:

NameTypeDescription
clsany类。

Return Value:

  • string: 归档类名。

实例成员 (Instance members)

initForWritingWithMutableData

用可变数据初始化(用于增量编码)。

initForWritingWithMutableData(data: NSMutableData): void

Parameters:

NameTypeDescription
dataNSMutableData目标数据。

Return Value:

  • 无。

setDelegate

设置委托。

setDelegate(delegate: any): void

Parameters:

NameTypeDescription
delegateany委托对象。

Return Value:

  • 无。

delegate

委托。

delegate(): any

Return Value:

  • any: 委托对象。

setOutputFormat

设置输出格式。

setOutputFormat(format: number): void

Parameters:

NameTypeDescription
formatnumber格式。

Return Value:

  • 无。

outputFormat

输出格式。

outputFormat(): number

Return Value:

  • number: 格式。

setRequiresSecureCoding

设置是否要求安全编码。

setRequiresSecureCoding(b: boolean): void

Parameters:

NameTypeDescription
bboolean是否要求。

Return Value:

  • 无。

encodeObjectForKey

编码对象。

encodeObjectForKey(objv: any, key: string): void

Parameters:

NameTypeDescription
objvany对象。
keystring键。

Return Value:

  • 无。

encodeConditionalObjectForKey

条件编码对象。

encodeConditionalObjectForKey(objv: any, key: string): void

Parameters:

NameTypeDescription
objvany对象。
keystring键。

Return Value:

  • 无。

encodeBoolForKey

编码布尔。

encodeBoolForKey(boolv: boolean, key: string): void

Parameters:

NameTypeDescription
boolvboolean值。
keystring键。

Return Value:

  • 无。

encodeIntForKey

编码 int。

encodeIntForKey(intv: number, key: string): void

Parameters:

NameTypeDescription
intvnumber值。
keystring键。

Return Value:

  • 无。

encodeInt32ForKey

编码 int32。

encodeInt32ForKey(intv: number, key: string): void

Parameters:

NameTypeDescription
intvnumber值。
keystring键。

Return Value:

  • 无。

encodeInt64ForKey

编码 int64。

encodeInt64ForKey(intv: number, key: string): void

Parameters:

NameTypeDescription
intvnumber值。
keystring键。

Return Value:

  • 无。

encodeFloatForKey

编码 float。

encodeFloatForKey(realv: number, key: string): void

Parameters:

NameTypeDescription
realvnumber值。
keystring键。

Return Value:

  • 无。

encodeDoubleForKey

编码 double。

encodeDoubleForKey(realv: number, key: string): void

Parameters:

NameTypeDescription
realvnumber值。
keystring键。

Return Value:

  • 无。

encodeBytesLengthForKey

编码字节数组。

encodeBytesLengthForKey(bytesp: any, lenv: number, key: string): void

Parameters:

NameTypeDescription
bytespany字节指针。
lenvnumber长度。
keystring键。

Return Value:

  • 无。

finishEncoding

完成编码。

finishEncoding(): void

Return Value:

  • 无。
头文件API清单

正在加载...

协议:JSBNSKeyedArchiver,来源:-