<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XcodeKit",
  "identifier" : "/documentation/XcodeKit/XCSourceTextRange",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "XcodeKit"
    ],
    "preciseIdentifier" : "c:objc(cs)XCSourceTextRange"
  },
  "title" : "XCSourceTextRange"
}
-->

# XCSourceTextRange

A half-open range of text in a buffer you use to select text or specify the insertion point for new text.

```
class XCSourceTextRange
```

## Overview

Source text ranges are half-open ranges. As a result, source text ranges include the character at the start position but exclude the character at the end position.

A range with equal start and end positions may be used to indicate a point within the buffer, such as an insertion point. The `start` and `end` position may be improperly ordered while you prepare them in your own code, but must be properly ordered before passing an `XCSourceTextRange` instance to other methods.

## Topics

### Creating Source Text Ranges

[`init(start: XCSourceTextPosition, end: XCSourceTextPosition)`](/documentation/XcodeKit/XCSourceTextRange/init(start:end:))

Creates a new source text range defined by its starting and ending positions.

### Getting the Bounds of Source Text Ranges

[`var start: XCSourceTextPosition`](/documentation/XcodeKit/XCSourceTextRange/start)

The start position of the range.

[`var end: XCSourceTextPosition`](/documentation/XcodeKit/XCSourceTextRange/end)

The end position of the range.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

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

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)