DekGenius.com
[ Team LiB ] Previous Section Next Section

NSMutableData Mac OS X 10.0

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.

figs/cocn_1360.gif

@interface NSMutableData : NSData
 // Initializers
   - (id)initWithCapacity:(unsigned)capacity;
   - (id)initWithLength:(unsigned)length;
 // Accessor Methods
   - (void)setData:(NSData *)data;
   - (void)setLength:(unsigned)length;
 // Class Methods
   + (id)dataWithCapacity:(unsigned)aNumItems;
   + (id)dataWithLength:(unsigned)length;
 // Instance Methods
   - (void)appendBytes:(const void *)bytes length:(unsigned)length;
   - (void)appendData:(NSData *)other;
   - (void)increaseLengthBy:(unsigned)extraLength;
   - (void *)mutableBytes;
   - (void)replaceBytesInRange:(NSRange)range withBytes:(const void *)bytes;
   - (void)replaceBytesInRange:(NSRange)range  withBytes:(const void *)replacementBytes
        length:(unsigned)replacementLength;
   - (void)resetBytesInRange:(NSRange)range;
   - (void)serializeAlignedBytesLength:(unsigned)length;
   - (void)serializeDataAt:(const void *)data ofObjCType:(const char *)type
         context:(id <NSObjCTypeSerializationCallBack>)callback;
   - (void)serializeInt:(int)value;
   - (void)serializeInt:(int)value atIndex:(unsigned)index;
   - (void)serializeInts:(int *)intBuffer count:(unsigned)numInts;
   - (void)serializeInts:(int *)intBuffer count:(unsigned)numInts atIndex:(unsigned)index;

    [ Team LiB ] Previous Section Next Section