NSMutableData
NSMutableData 是可变的二进制数据缓冲区,可用于构造/拼接二进制内容(例如网络 body、文件数据块等)。
类成员 (Class members)
Section titled “类成员 (Class members)”dataWithCapacity
Section titled “dataWithCapacity”预分配容量创建。
static dataWithCapacity(aNumItems: number): NSMutableDataParameters:
| Name | Type | Description |
|---|---|---|
aNumItems | number | 初始容量(字节数)。 |
Return Value:
NSMutableData: 新实例。
dataWithLength
Section titled “dataWithLength”创建指定长度的数据(零填充)。
static dataWithLength(length: number): NSMutableDataParameters:
| Name | Type | Description |
|---|---|---|
length | number | 长度(字节)。 |
Return Value:
NSMutableData: 新实例。
实例成员 (Instance members)
Section titled “实例成员 (Instance members)”mutableBytes
Section titled “mutableBytes”可变字节指针(用于直接写入)。
mutableBytes(): anyReturn Value:
any: 字节缓冲区指针。
setLength
Section titled “setLength”设置数据长度。
setLength(length: number): voidParameters:
| Name | Type | Description |
|---|---|---|
length | number | 新长度(字节)。 |
Return Value:
- 无。
increaseLengthBy
Section titled “increaseLengthBy”增加长度。
increaseLengthBy(extraLength: number): voidParameters:
| Name | Type | Description |
|---|---|---|
extraLength | number | 要增加的字节数。 |
Return Value:
- 无。
appendBytesLength
Section titled “appendBytesLength”在末尾追加字节。
appendBytesLength(bytes: any, length: number): voidParameters:
| Name | Type | Description |
|---|---|---|
bytes | any | 字节序列。 |
length | number | 字节数。 |
Return Value:
- 无。
appendData
Section titled “appendData”在末尾追加另一 NSData。
appendData(other: NSData): voidParameters:
| Name | Type | Description |
|---|---|---|
other | NSData | 要追加的数据。 |
Return Value:
- 无。
replaceBytesInRangeWithBytes
Section titled “replaceBytesInRangeWithBytes”在范围内替换为字节序列。
replaceBytesInRangeWithBytes(range: any, bytes: any): voidParameters:
| Name | Type | Description |
|---|---|---|
range | any | 范围(如 { location, length })。 |
bytes | any | 替换字节序列。 |
Return Value:
- 无。
replaceBytesInRangeWithBytesLength
Section titled “replaceBytesInRangeWithBytesLength”在范围内替换为指定长度的字节序列。
replaceBytesInRangeWithBytesLength(range: any, replacementBytes: any, replacementLength: number): voidParameters:
| Name | Type | Description |
|---|---|---|
range | any | 范围。 |
replacementBytes | any | 替换字节序列。 |
replacementLength | number | 替换长度。 |
Return Value:
- 无。
resetBytesInRange
Section titled “resetBytesInRange”将范围内字节置零。
resetBytesInRange(range: any): voidParameters:
| Name | Type | Description |
|---|---|---|
range | any | 范围。 |
Return Value:
- 无。
setData
Section titled “setData”用另一 NSData 整体替换内容。
setData(data: NSData): voidParameters:
| Name | Type | Description |
|---|---|---|
data | NSData | 源数据。 |
Return Value:
- 无。