NSKeyedArchiver
NSKeyedArchiver 用于把对象图归档为二进制数据(NSData)或写入文件。
类成员 (Class members)
Section titled “类成员 (Class members)”archivedDataWithRootObject
Section titled “archivedDataWithRootObject”将根对象归档为 NSData。
static archivedDataWithRootObject(rootObject: any): NSDataParameters:
| Name | Type | Description |
|---|---|---|
rootObject | any | 根对象(需支持 NSCoding)。 |
Return Value:
NSData: 归档数据。
archiveRootObjectToFile
Section titled “archiveRootObjectToFile”将根对象归档到文件。
static archiveRootObjectToFile(rootObject: any, path: string): booleanParameters:
| Name | Type | Description |
|---|---|---|
rootObject | any | 根对象。 |
path | string | 文件路径。 |
Return Value:
boolean: 是否成功。
setClassNameForClass
Section titled “setClassNameForClass”设置类名映射(归档用)。
static setClassNameForClass(codedName: string, cls: any): voidParameters:
| Name | Type | Description |
|---|---|---|
codedName | string | 归档中的类名。 |
cls | any | 实际类。 |
Return Value:
- 无。
classNameForClass
Section titled “classNameForClass”取类的归档名。
static classNameForClass(cls: any): stringParameters:
| Name | Type | Description |
|---|---|---|
cls | any | 类。 |
Return Value:
string: 归档类名。
实例成员 (Instance members)
Section titled “实例成员 (Instance members)”initForWritingWithMutableData
Section titled “initForWritingWithMutableData”用可变数据初始化(用于增量编码)。
initForWritingWithMutableData(data: NSMutableData): voidParameters:
| Name | Type | Description |
|---|---|---|
data | NSMutableData | 目标数据。 |
Return Value:
- 无。
setDelegate
Section titled “setDelegate”设置委托。
setDelegate(delegate: any): voidParameters:
| Name | Type | Description |
|---|---|---|
delegate | any | 委托对象。 |
Return Value:
- 无。
delegate
Section titled “delegate”委托。
delegate(): anyReturn Value:
any: 委托对象。
setOutputFormat
Section titled “setOutputFormat”设置输出格式。
setOutputFormat(format: number): voidParameters:
| Name | Type | Description |
|---|---|---|
format | number | 格式。 |
Return Value:
- 无。
outputFormat
Section titled “outputFormat”输出格式。
outputFormat(): numberReturn Value:
number: 格式。
setRequiresSecureCoding
Section titled “setRequiresSecureCoding”设置是否要求安全编码。
setRequiresSecureCoding(b: boolean): voidParameters:
| Name | Type | Description |
|---|---|---|
b | boolean | 是否要求。 |
Return Value:
- 无。
encodeObjectForKey
Section titled “encodeObjectForKey”编码对象。
encodeObjectForKey(objv: any, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
objv | any | 对象。 |
key | string | 键。 |
Return Value:
- 无。
encodeConditionalObjectForKey
Section titled “encodeConditionalObjectForKey”条件编码对象。
encodeConditionalObjectForKey(objv: any, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
objv | any | 对象。 |
key | string | 键。 |
Return Value:
- 无。
encodeBoolForKey
Section titled “encodeBoolForKey”编码布尔。
encodeBoolForKey(boolv: boolean, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
boolv | boolean | 值。 |
key | string | 键。 |
Return Value:
- 无。
encodeIntForKey
Section titled “encodeIntForKey”编码 int。
encodeIntForKey(intv: number, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
intv | number | 值。 |
key | string | 键。 |
Return Value:
- 无。
encodeInt32ForKey
Section titled “encodeInt32ForKey”编码 int32。
encodeInt32ForKey(intv: number, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
intv | number | 值。 |
key | string | 键。 |
Return Value:
- 无。
encodeInt64ForKey
Section titled “encodeInt64ForKey”编码 int64。
encodeInt64ForKey(intv: number, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
intv | number | 值。 |
key | string | 键。 |
Return Value:
- 无。
encodeFloatForKey
Section titled “encodeFloatForKey”编码 float。
encodeFloatForKey(realv: number, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
realv | number | 值。 |
key | string | 键。 |
Return Value:
- 无。
encodeDoubleForKey
Section titled “encodeDoubleForKey”编码 double。
encodeDoubleForKey(realv: number, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
realv | number | 值。 |
key | string | 键。 |
Return Value:
- 无。
encodeBytesLengthForKey
Section titled “encodeBytesLengthForKey”编码字节数组。
encodeBytesLengthForKey(bytesp: any, lenv: number, key: string): voidParameters:
| Name | Type | Description |
|---|---|---|
bytesp | any | 字节指针。 |
lenv | number | 长度。 |
key | string | 键。 |
Return Value:
- 无。
finishEncoding
Section titled “finishEncoding”完成编码。
finishEncoding(): voidReturn Value:
- 无。