Next Page > Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

NSMutableData

Inherits from
Implements
Package
com.apple.cocoa.foundation
Companion guide

Class at a Glance

An NSMutableData object stores mutable data in the form of bytes. The size of the data is subject to a 2GB limit.

Principal Attributes

Creation

NSMutableData

Creates an NSMutableData object.

Primitive Methods

setLength

Extends or truncates the number of bytes in the NSMutableData object.

Overview

NSMutableData (and its superclass NSData) provide data objects, object-oriented wrappers for byte buffers. Data objects let simple allocated buffers (that is, data with no embedded pointers) take on the behavior of Foundation objects. They are typically used for data storage and are also useful in Distributed Objects applications, where data contained in data objects can be copied or moved between applications. NSData creates static data objects, and NSMutableData creates dynamic data objects. You can easily convert one type of data object to the other with the constructor that takes an NSData or NSMutableData as an argument.

Tasks

Constructors

Adjusting Capacity

Adding Data

Modifying Data

Constructors

NSMutableData

public NSMutableData()

Discussion

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

public NSMutableData(java.net.URL aURL)

Discussion

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

public NSMutableData(NSData aData)

Discussion

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

public NSMutableData(int length)

Discussion

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

Instance Methods

appendData

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

public void appendData(NSData otherData)

increaseLengthBy

Increases the length of the receiver by extraLength.

public void increaseLengthBy(int extraLength)

Discussion

The additional bytes are all set to 0.

See Also

resetBytesInRange

Specifies a range within the contents of the receiver to be replaced by zeros.

public void resetBytesInRange(NSRange range)

Discussion

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

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

public void setData(NSData aData)

setLength

Extends or truncates a mutable data object to length.

public void setLength(int length)

Discussion

If the mutable data object is extended, the additional bytes are filled with zeros.

See Also


Next Page > Hide TOC


© 1997, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-24)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.