Error:

Increase the mutable data length

[mutableData increaseLengthBy:256];

Change length of the mutable data

[mutableData setLength:256];

Get pointer to the actual data of NSMutableData object

unsigned char *bytes = (unsigned char*)[mutableData mutableBytes];

Append bytes to the mutable data

unsigned char *buffer;
[mutableData appendBytes:buffer length:bufferLength];

Append data to the mutable data

[mutableData appendData:anotherData];

Replace chunk of bytes in the mutable data with same length chunk

unsigned char *buffer;
// allocate and init buffer LEN bytes long
[mutableData replaceBytesInRange:NSMakeRange(10, LEN) withBytes:buffer];

Replace chunk of bytes in the mutable data with different length chunk

unsigned char *buffer;
// allocate and init buffer LEN bytes long
[mutableData replaceBytesInRange:NSMakeRange(10, 5) withBytes:buffer length:LEN];
// 5 bytes replaced with LEN bytes

Remove chunk from the mutable data

// remove 5 bytes starting from 10th
[mutableData replaceBytesInRange:NSMakeRange(10, 5) withBytes:NULL length:0];

Insert chunk to the mutable data

// insert 5 bytes starting starting at 10th
[mutableData replaceBytesInRange:NSMakeRange(10, 0) withBytes:buffer length:5];

Fill chunk of the mutable data with zeroes

// fill mutableData with zeroes
[mutableData resetBytesInRange:NSMakeRange(0, [mutableData length])];

Assign data to the mutable data

[mutableData setData:anotherData];