Name
NSMutableData — Mac OS X 10.0
Synopsis
This class adds mutable functionality to NSData,
allowing the contents of the data
object to be altered after
initialization. NSMutableData provides two methods
for adjusting the size of the underlying data buffer:
increaseLengthBy:,and
setLength:. The first of these increases the size
of the buffer by the indicated number of bytes, while the latter sets
the size of the buffer to the specified number of bytes.
Data is added to a mutable data object using either
appendData: or
appendBytes:length. appendData:
joins the specified NSData object to the end of
the receiver, while appendBytes:length: appends to
the receiver the number of bytes specified in length from the buffer
pointer to in the first parameter.
NSMutableData also provides
replaceBytesInRange:withBytes: and
replaceBytesInRange:withBytes:length: to directly
alter the contents of the underlying data buffer. If you want to zero
a portion of data, use the method
resetBytesInRange:.
NSMutableData is toll-free bridged with the Core
Foundation type CFData. As such,
NSMutableData objects can be used interchangeably
with the CFData pointer type,
CFDataRef.
|
![]()
|
@interface NSMutableData : NSData
|
// Initializers
|
- (id)initWithCapacity:(unsigned)capacity; |
- (id)initWithLength:(unsigned)length; |
// Accessor Methods
|
- (void)setData:(NSData *)data; |
- (void)setLength:(unsigned)length ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
