Next Page > Hide TOC

Legacy Documentclose button

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

NSMutableRange

Inherits from
NSRange : Object
Package
com.apple.cocoa.foundation
Companion guide
Geometry and Range Utilities

Overview

An NSMutableRange is an object representing a range that can be changed. A range is a measurement of a segment of something linear, such as a byte stream. You can change an NSMutableRange’s two primary values, its location and its length. The methods of NSMutableRange also enable you to alter an NSMutableRange based on its union or intersection with another NSRange object.

The main purpose for NSMutableRanges is to provide a way for methods to return range values in an “out” parameter. A client creates and passes in one or more NSMutableRanges to a method and gets back changed objects when the method returns. NSMutableRanges are also useful for performance reasons; instead of creating multiple NSRanges in a loop, you can create just one NSMutableRange and reuse it.

Tasks

Constructors

Accessing and Setting Range Elements

Transforming Mutable Ranges

Constructors

NSMutableRange

public NSMutableRange()

Discussion

Initializes the object to an empty NSMutableRange.

public NSMutableRange(int location, int length)

Discussion

Initializes the NSMutableRange with the range elements of location and length. Throws an IllegalArgumentException if either integer is negative.

public NSMutableRange(NSRange aRange)

Discussion

Initializes the new NSMutableRange with the location and length values of aRange; this constructor is used in cloning the receiver.

Instance Methods

clone

Creates and returns a copy of the receiver.

public Object clone()

intersectRange

Changes the receiver to the range resulting from the intersection of aRange and the receiver before the operation.

public void intersectRange(NSRange aRange)

Discussion

Sets the receiver to an empty range if they do not intersect.

See Also

length

Returns the length of the receiver, its distance from its starting location.

public int length()

Discussion

NSMutableRange overrides this method because of internal implementation requirements.

See Also

location

Returns the starting location of the receiver.

public int location()

Discussion

NSMutableRange overrides this method because of internal implementation requirements.

See Also

setLength

Sets the length of the receiver to newLength.

public void setLength(int newLength)

Discussion

Throws an IllegalArgumentException if newLength is a negative value.

See Also

setLocation

Sets the length of the receiver to newLocation.

public void setLocation(int newLocation)

Discussion

Throws an IllegalArgumentException if newLocation is a negative value.

See Also

unionRange

Changes the receiver to the range resulting from the union of aRange and the receiver.

public void unionRange(NSRange aRange)

Discussion

The result is a range with the lowest starting location and the highest ending location of the two NSRanges.

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.