<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSTextCheckingResult",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextCheckingResult"
  },
  "title" : "NSTextCheckingResult"
}
-->

# NSTextCheckingResult

An occurrence of textual content found during the analysis of a block of text, such as when matching a regular expression.

```
class NSTextCheckingResult
```

## Overview

On both iOS and macOS, instances of [`NSTextCheckingResult`](/documentation/Foundation/NSTextCheckingResult) are returned by the [`NSRegularExpression`](/documentation/Foundation/NSRegularExpression) class and the [`NSDataDetector`](/documentation/Foundation/NSDataDetector) class to indicate the discovery of content. In those cases, what is found may be a match for a regular expression or a date, address, phone number, and so on. In macOS, instances of `NSTextCheckingResult` are returned by the <doc://com.apple.documentation/documentation/AppKit/NSSpellChecker> object to describe the results of spelling, grammar, or text-substitution actions.

## Topics

### Text Checking Type Range and Type

[`range`](/documentation/Foundation/NSTextCheckingResult/range)

Returns the range of the result that the receiver represents.

[`resultType`](/documentation/Foundation/NSTextCheckingResult/resultType)

Returns the text checking result type that the receiver represents.

[`numberOfRanges`](/documentation/Foundation/NSTextCheckingResult/numberOfRanges)

Returns the number of ranges.

[`-  rangeAtIndex:`](/documentation/Foundation/NSTextCheckingResult/range(at:))

Returns the result type that the range represents.

### Text Checking Results for Text Replacement

[`+  replacementCheckingResultWithRange:replacementString:`](/documentation/Foundation/NSTextCheckingResult/replacementCheckingResult(range:replacementString:))

Creates and returns a text checking result with the specified replacement string.

[`replacementString`](/documentation/Foundation/NSTextCheckingResult/replacementString)

A replacement string from one of a number of replacement checking results.

### Text Checking Results for Regular Expressions

[`+  regularExpressionCheckingResultWithRanges:count:regularExpression:`](/documentation/Foundation/NSTextCheckingResult/regularExpressionCheckingResult(ranges:count:regularExpression:))

Creates and returns a type checking result with the specified regular expression data.

[`regularExpression`](/documentation/Foundation/NSTextCheckingResult/regularExpression)

The regular expression of a type checking result.

### Text Checking Result Components

[`components`](/documentation/Foundation/NSTextCheckingResult/components)

A dictionary containing the components of a type checking result.

### Text Checking Results for URLs

[`+  linkCheckingResultWithRange:URL:`](/documentation/Foundation/NSTextCheckingResult/linkCheckingResult(range:url:))

Creates and returns a text checking result with the specified URL.

[`URL`](/documentation/Foundation/NSTextCheckingResult/url)

The URL of a type checking result.

### Text Checking Results for Addresses

[`+  addressCheckingResultWithRange:components:`](/documentation/Foundation/NSTextCheckingResult/addressCheckingResult(range:components:))

Creates and returns a text checking result with the specified address components.

[`addressComponents`](/documentation/Foundation/NSTextCheckingResult/addressComponents)

The address dictionary of a type checking result.

### Text Checking Results for Transit Information

[`+  transitInformationCheckingResultWithRange:components:`](/documentation/Foundation/NSTextCheckingResult/transitInformationCheckingResult(range:components:))

Creates and returns a text checking result with the specified transit information.

### Text Checking Results for Phone Numbers

[`+  phoneNumberCheckingResultWithRange:phoneNumber:`](/documentation/Foundation/NSTextCheckingResult/phoneNumberCheckingResult(range:phoneNumber:))

Creates and returns a text checking result with the specified phone number.

[`phoneNumber`](/documentation/Foundation/NSTextCheckingResult/phoneNumber)

The phone number of a type checking result.

### Text Checking Results for Dates and Times

[`+  dateCheckingResultWithRange:date:`](/documentation/Foundation/NSTextCheckingResult/dateCheckingResult(range:date:))

Creates and returns a text checking result with the specified date.

[`+  dateCheckingResultWithRange:date:timeZone:duration:`](/documentation/Foundation/NSTextCheckingResult/dateCheckingResult(range:date:timeZone:duration:))

Creates and returns a text checking result with the specified date, time zone, and duration.

[`date`](/documentation/Foundation/NSTextCheckingResult/date)

The date component of a type checking result.

[`duration`](/documentation/Foundation/NSTextCheckingResult/duration)

The duration component of a type checking result.

[`timeZone`](/documentation/Foundation/NSTextCheckingResult/timeZone)

The time zone component of a type checking result.

### Text Checking Results for Typography

[`+  dashCheckingResultWithRange:replacementString:`](/documentation/Foundation/NSTextCheckingResult/dashCheckingResult(range:replacementString:))

Creates and returns a text checking result with the specified dash corrected replacement string.

[`+  quoteCheckingResultWithRange:replacementString:`](/documentation/Foundation/NSTextCheckingResult/quoteCheckingResult(range:replacementString:))

Creates and returns a text checking result with the specified quote-balanced replacement string.

### Text Checking Results for Spelling

[`+  spellCheckingResultWithRange:`](/documentation/Foundation/NSTextCheckingResult/spellCheckingResult(range:))

Creates and returns a text checking result with the range of a misspelled word.

[`+  correctionCheckingResultWithRange:replacementString:`](/documentation/Foundation/NSTextCheckingResult/correctionCheckingResult(range:replacementString:))

Creates and returns a text checking result after detecting a possible correction.

### Text Checking Results for Orthography

[`+  orthographyCheckingResultWithRange:orthography:`](/documentation/Foundation/NSTextCheckingResult/orthographyCheckingResult(range:orthography:))

Creates and returns a text checking result with the specified orthography.

[`orthography`](/documentation/Foundation/NSTextCheckingResult/orthography)

The detected orthography of a type checking result.

### Text Checking Results for Grammar

[`+  grammarCheckingResultWithRange:details:`](/documentation/Foundation/NSTextCheckingResult/grammarCheckingResult(range:details:))

Creates and returns a text checking result with the specified array of grammatical errors.

[`grammarDetails`](/documentation/Foundation/NSTextCheckingResult/grammarDetails)

The details of a located grammatical type checking result.

### Adjusting the Ranges of a Text Checking Result

[`-  resultByAdjustingRangesWithOffset:`](/documentation/Foundation/NSTextCheckingResult/adjustingRanges(offset:))

Returns a new text checking result after adjusting the ranges as specified by the offset.

### Constants

[Keys for Transit Components](/documentation/Foundation/keys-for-transit-components)

The following constants identify the possible keys returned in the components dictionary.

[Keys for Address Components](/documentation/Foundation/keys-for-address-components)

The following constants identify the possible keys returned in the [`addressComponents`](/documentation/Foundation/NSTextCheckingResult/addressComponents) dictionary.

[`CheckingType`](/documentation/Foundation/NSTextCheckingResult/CheckingType)

These constants specify the type of checking the methods should do. They are returned by [`resultType`](/documentation/Foundation/NSTextCheckingResult/resultType).

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

Defines the types of checking that are available. These values can be combined using the C-bitwise OR operator. The system supports its own internal types, and the user can extend those types by subclassing `NSTextCheckingResult` and adding their own custom types.

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

[Anonymous](/documentation/Foundation/1476845-anonymous)

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

### 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)