PATH |
- Inherits from:
- Object
- Implements:
- Cloneable
- Serializable
- Package:
- com.webobjects.foundation
An NSRange represents a range, a measurement of a segment of something linear, such as a byte stream. An NSRange has two primary values, a location and a length. The methods of NSRange give access to these values, convert between NSRanges and their string representations, test and compare ranges, and create ranges based on operations involving the union, intersection, and subtraction of two ranges.
Table 0-12 describes the NSRange methods that provide the basis for all NSRange's other methods; that is, all other methods are implemented in terms of these two. If you create a subclass of NSRange, you need only ensure that these base methods work properly. Having done so, you can be sure that all your subclass's inherited methods operate properly.
Method | Description |
length | Returns the length of the receiver from its starting location. |
location | Returns the starting location of the receiver. |
NSRange provides the following constant as a convenience; you can use it to compare values returned by some NSRange methods:
Constant | Type | Description |
ZeroRange | NSRange | An NSRange set to zero in location and length. |
- Cloneable
- clone
- Constructors
- NSRange
- Accessing range elements
- length
- location
- Manipulating ranges
- rangeByIntersectingRange
- rangeByUnioningRange
- subtractRange
- Testing ranges
- containsLocation
- intersectsRange
- isEmpty
- isEqualToRange
- isSubrangeOfRange
- locationInRange
- maxRange
- Methods inherited from Object
- equals
- hashCode
- toString
- Converting Strings to NSRanges
- fromString
public NSRange()
ZeroRange
shared instance. See Constants.
public NSRange(NSRange aRange)
public NSRange( int location, int length)
public static NSRange fromString(String rangeAsString)
See Also: toString
public Object clone()
public boolean containsLocation(int aLocation)
See Also: intersectsRange, location
public boolean equals(Object otherObject)
See Also: isEqualToRange, isSubrangeOfRange
public int hashCode()
public boolean intersectsRange(NSRange aRange)
See Also: rangeByIntersectingRange
public boolean isEmpty()
See Also: maxRange
public boolean isEqualToRange(NSRange aRange)
See Also: equals, isSubrangeOfRange
public boolean isSubrangeOfRange(NSRange aRange)
See Also: intersectsRange
public int length()
See Also: location
public int location()
See Also: length
public boolean locationInRange(int aLocation)
public int maxRange()
See Also: isEmpty, length, location
public NSRange rangeByIntersectingRange(NSRange aRange)
See Also: rangeByUnioningRange, subtractRange
public NSRange rangeByUnioningRange(NSRange aRange)
See Also: rangeByIntersectingRange, subtractRange
public void subtractRange( NSRange otherRange, NSMutableRange resultRange1, NSMutableRange resultRange2)
See Also: rangeByIntersectingRange, rangeByUnioningRange
public String toString()
See Also: fromString
© 2001 Apple Computer, Inc. (Last Published April 17, 2001)