<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSRange-c.struct",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@S@_NSRange"
  },
  "title" : "NSRange"
}
-->

# NSRange

A structure used to describe a portion of a series, such as characters in a string or objects in an array.

```
typedef struct _NSRange { ... } NSRange;
```

## Discussion

Foundation functions that operate on ranges include the following:

- [`NSEqualRanges(_:_:)`](/documentation/Foundation/NSEqualRanges(_:_:))
- [`NSIntersectionRange(_:_:)`](/documentation/Foundation/NSIntersectionRange(_:_:))
- [`NSLocationInRange(_:_:)`](/documentation/Foundation/NSLocationInRange(_:_:))
- [`NSMakeRange(_:_:)`](/documentation/Foundation/NSMakeRange(_:_:))
- [`NSMaxRange(_:)`](/documentation/Foundation/NSMaxRange(_:))
- [`NSRangeFromString(_:)`](/documentation/Foundation/NSRangeFromString(_:))
- [`NSStringFromRange(_:)`](/documentation/Foundation/NSStringFromRange(_:))
- [`NSUnionRange(_:_:)`](/documentation/Foundation/NSUnionRange(_:_:))

## Topics

### Managing ranges

[`NSEqualRanges`](/documentation/Foundation/NSEqualRanges(_:_:))

Returns a Boolean value that indicates whether two given ranges are equal.

[`NSIntersectionRange`](/documentation/Foundation/NSIntersectionRange(_:_:))

Returns the intersection of the specified ranges.

[`NSLocationInRange`](/documentation/Foundation/NSLocationInRange(_:_:))

Returns a Boolean value that indicates whether a specified position is in a given range.

[`NSMakeRange`](/documentation/Foundation/NSMakeRange(_:_:))

Creates a new NSRange from the specified values.

[`NSMaxRange`](/documentation/Foundation/NSMaxRange(_:))

Returns the sum of the location and length of the range.

[`NSRangeFromString`](/documentation/Foundation/NSRangeFromString(_:))

Returns a range from a textual representation.

[`NSStringFromRange`](/documentation/Foundation/NSStringFromRange(_:))

Returns a string representation of a range.

[`NSUnionRange`](/documentation/Foundation/NSUnionRange(_:_:))

Returns the union of the specified ranges.

### Related types

[`NSRangePointer`](/documentation/Foundation/NSRangePointer)

Type indicating a parameter is a pointer to an `NSRange` structure.

[`NSNotFound`](/documentation/Foundation/NSNotFound-4qp9h)

A value indicating that a requested item couldn’t be found or doesn’t exist.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)