PATH  Documentation > Mac OS X > Foundation Reference: Java



Table of Contents

NSMutableData


Inherits from:
NSData : NSObject
Package:
com.apple.yellow.foundation

Class at a Glance


An NSMutableData object stores mutable data in the form of bytes.

Principal Attributes


Creation



NSMutableData Creates an NSMutableData object


Class Description


The NSMutableData class declares the programmatic interface to an object that contains modifiable data in the form of bytes. setLength allows you to truncate or extend the length of a mutable data object.

increaseLengthBy also allows you to change the length of a mutable data object.

The appendData method lets you append bytes or the contents of another data object to a mutable data object. You can replace a range of bytes in a mutable data object with zeros (using the resetBytesInRange method).




Method Types


Constructors
NSMutableData
Adjusting capacity
increaseLengthBy
setLength
Adding data
appendData
Modifying data
resetBytesInRange
setData


Constructors



NSMutableData

public NSMutableData()

Creates an empty data object. This method is declared primarily for the use of mutable subclasses of NSData.

public NSMutableData(java.net.URL anURL)

Creates a data object with the data from the location specified by anURL.

public NSMutableData(NSData aData)

Creates a data object containing the contents of another data object, aData.

public NSMutableData(int length)

Creates data object with enough memory to hold length bytes. Fills the object with zeros up to length.




Instance Methods



appendData

public void appendData(NSData otherData)

Appends the contents of a data object otherData to the receiver.



increaseLengthBy

public void increaseLengthBy(int extraLength)

Increases the length of the receiver by extraLength. The additional bytes are all set to zero.

See Also: setLength



resetBytesInRange

public void resetBytesInRange(NSRange range)

Specifies a range within the contents of a mutable data object to be replaced by zeros. If the location of range isn't within the receiver's range of bytes, a RangeException is thrown. The receiver is resized to accommodate the new bytes, if necessary.



setData

public void setData(NSData aData)

Replaces the entire contents of the receiver with the contents of aData.



setLength

public void setLength(int length)

Extends or truncates a mutable data object to length. If the mutable data object is extended, the additional bytes are filled with zero.

See Also: increaseLengthBy




Table of Contents