Class

NSTextCheckingResult

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

Declaration

@interface NSTextCheckingResult : NSObject

Overview

On both iOS and macOS, instances of NSTextCheckingResult are returned by the NSRegularExpression class and the 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 NSSpellChecker object to describe the results of spelling, grammar, or text-substitution actions.

Topics

Text Checking Type Range and Type

range

Returns the range of the result that the receiver represents.

resultType

Returns the text checking result type that the receiver represents.

numberOfRanges

Returns the number of ranges.

- rangeAtIndex:

Returns the result type that the range represents.

Text Checking Results for Text Replacement

+ replacementCheckingResultWithRange:replacementString:

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

replacementString

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

Text Checking Results for Regular Expressions

+ regularExpressionCheckingResultWithRanges:count:regularExpression:

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

regularExpression

The regular expression of a type checking result.

Text Checking Result Components

components

A dictionary containing the components of a type checking result.

Text Checking Results for URLs

+ linkCheckingResultWithRange:URL:

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

URL

The URL of a type checking result.

Text Checking Results for Addresses

+ addressCheckingResultWithRange:components:

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

addressComponents

The address dictionary of a type checking result.

Text Checking Results for Transit Information

+ transitInformationCheckingResultWithRange:components:

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

Text Checking Results for Phone Numbers

+ phoneNumberCheckingResultWithRange:phoneNumber:

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

phoneNumber

The phone number of a type checking result.

Text Checking Results for Dates and Times

+ dateCheckingResultWithRange:date:

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

+ dateCheckingResultWithRange:date:timeZone:duration:

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

date

The date component of a type checking result.

duration

The duration component of a type checking result.

timeZone

The time zone component of a type checking result.

Text Checking Results for Typography

+ dashCheckingResultWithRange:replacementString:

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

+ quoteCheckingResultWithRange:replacementString:

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

Text Checking Results for Spelling

+ spellCheckingResultWithRange:

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

+ correctionCheckingResultWithRange:replacementString:

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

Text Checking Results for Orthography

+ orthographyCheckingResultWithRange:orthography:

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

orthography

The detected orthography of a type checking result.

Text Checking Results for Grammar

+ grammarCheckingResultWithRange:details:

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

grammarDetails

The details of a located grammatical type checking result.

Adjusting the Ranges of a Text Checking Result

- resultByAdjustingRangesWithOffset:

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

Constants

Keys for Transit Components

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

Keys for Address Components

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

NSTextCheckingType

These constants specify the type of checking the methods should do. They are returned by resultType.

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.

Instance Properties

Instance Methods

Relationships

Inherits From

See Also

Pattern Matching

NSScanner

A string parser that scans for substrings or characters in a character set, and for numeric values from decimal, hexadecimal, and floating-point representations.

NSRegularExpression

An immutable representation of a compiled regular expression that you apply to Unicode strings.

NSDataDetector

A specialized regular expression object that matches natural language text for predefined data patterns.

NSNotFound

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