[Previous] [Up] [Next]

NSMutableData

Authors

Richard Frith-Macdonald

Version: $Revision$

Date: $Date$

NSMutableData

NSMutableData

Declared in: Foundation/NSData.h

Conforms to: NSCoding


Instance Variables

Methods


Class Methods

allocWithZone:

+ (id) allocWithZone: (NSZone*)zone;

dataWithCapacity:

+ (id) dataWithCapacity: (unsigned int)aNumItems;

dataWithLength:

+ (id) dataWithLength: (unsigned int)length;


Instances Methods

appendBytes:length:

- (void) appendBytes: (const void*)bytes length: (unsigned int)length;

appendData:

- (void) appendData: (NSData*)otherData;

increaseLengthBy:

- (void) increaseLengthBy: (unsigned int)extraLength;

initWithCapacity:

- (id) initWithCapacity: (unsigned int)capacity;

initWithLength:

- (id) initWithLength: (unsigned int)length;

mutableBytes

- (void*) mutableBytes;

Returns a pointer to the data storage of the receiver.
Modifications to the memory pointed to by this pointer will change the contents of the object. It is important that your code should not try to modify the memory beyond the number of bytes given by the -length method.

NB. if the object is released, or any method that changes its size or content is called, then the pointer previously returned by this method may cease to be valid.

This is a 'primitive' method ... you need to implement it if you write a subclass of NSMutableData.


replaceBytesInRange:withBytes:

- (void) replaceBytesInRange: (NSRange)range withBytes: (const void*)bytes;

Replaces the bytes of data in the specified range with a copy of the new bytes supplied.
If the location of the range specified lies beyond the end of the data ([self length] < range.location) then a range exception is raised.
Otherwise, if the range specified extends beyond the end of the data, then the size of the data is increased to accomodate the new bytes.


resetBytesInRange:

- (void) resetBytesInRange: (NSRange)range;

serializeAlignedBytesLength:

- (void) serializeAlignedBytesLength: (unsigned int)length;

serializeDataAt:ofObjCType:context:

- (void) serializeDataAt: (const void*)data ofObjCType: (const char*)type context: (id<NSObjCTypeSerializationCallBack>)callback;

serializeInt:

- (void) serializeInt: (int)value;

serializeInt:atIndex:

- (void) serializeInt: (int)value atIndex: (unsigned int)index;

serializeInts:

- (void) serializeInts: (int*)intBuffer;

serializeInts:count:atIndex:

- (void) serializeInts: (int*)intBuffer count: (unsigned int)numInts atIndex: (unsigned int)index;

setData:

- (void) setData: (NSData*)aData;

setLength:

- (void) setLength: (unsigned int)length;

Sets the length of the NSMutableData object. If the length is increased, the newly allocated data area is filled with zero bytes.

This is a 'primitive' method ... you need to implement it if you write a subclass of NSMutableData.