Mac OS X Reference Library Apple Developer
Search

NSTextCheckingResult Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.6 and later.
Companion guide
Declared in
NSTextCheckingResult.h

Overview

NSTextCheckingResult is a class used to describe items located by text checking. Each of these objects represents something that has been found during checking–a misspelled word, a sentence with grammatical issues, a detected URL, a straight quote to be replaced with curly quotes, and so forth.

Instances of NSTextCheckingResult are returned by the NSSpellChecker to describe the results of spelling, grammar, or substitution actions.

Tasks

Checking Type Result and Location

Replacing Results

URL Checking

Address Checking

Date and Time Checking

Typography Checking

Spell Checking

Orthography

Grammar Checking

Properties

For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.

addressComponents

Returns a dictionary containing the address components for an NSTextCheckingTypeAddress result. (read-only)

@property(readonly) NSDictionary *addressComponents

Discussion

The dictionary keys are described in “Keys for Address Components.”

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

date

The date detected by dateCheckingResultWithRange:date: or dateCheckingResultWithRange:date:timeZone:duration: (read-only)

@property(readonly) NSDate *date

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

duration

The duration detected by dateCheckingResultWithRange:date:timeZone:duration: (read-only)

@property(readonly) NSTimeInterval duration

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

grammarDetails

The details of the grammatical error found by grammarCheckingResultWithRange:details: (read-only)

@property(readonly) NSArray *grammarDetails

Discussion

This array of strings is suitable for presenting to the user.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

orthography

The orthography detected by orthographyCheckingResultWithRange:orthography: (read-only)

@property(readonly) NSOrthography *orthography

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

range

Returns the range of the result that the receiver represents. (read-only)

@property(readonly) NSRange range

Discussion

This property will be present for all returned NSTextCheckingResult instances.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

replacementString

A replacement string from one of a number of replacement checking results.. (read-only)

@property(readonly) NSString *replacementString

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

resultType

Returns the result type that the receiver represents. (read-only)

@property(readonly) NSTextCheckingType resultType

Discussion

The possible result types for the built in checking capabilities are described in “NSTextCheckingType.”

This property will be present for all returned NSTextCheckingResult instances.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

timeZone

The time zone detected by dateCheckingResultWithRange:date:timeZone:duration: (read-only)

@property(readonly) NSTimeZone *timeZone

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

URL

Returns the URL found by a NSTextCheckingTypeLink result. (read-only)

@property(readonly) NSURL *URL

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

Class Methods

addressCheckingResultWithRange:components:

Creates and returns a text checking result after locating an address.

+ (NSTextCheckingResult *)addressCheckingResultWithRange:(NSRange)range components:(NSDictionary *)components

Parameters
range

The range of the detected result.

components

A dictionary containing the detected address components. The dictionary keys are described in “Keys for Address Components.”

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeAddress.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

correctionCheckingResultWithRange:replacementString:

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

+ (NSTextCheckingResult *)correctionCheckingResultWithRange:(NSRange)range replacementString:(NSString *)replacementString

Parameters
range

The range of the detected result.

replacementString

The suggested replacement string.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeSpelling.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

dashCheckingResultWithRange:replacementString:

Creates and returns a text checking result after locating a dash.

+ (NSTextCheckingResult *)dashCheckingResultWithRange:(NSRange)range replacementString:(NSString *)replacementString

Parameters
range

The range of the detected result.

replacementString

The replacement string.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeDash.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

dateCheckingResultWithRange:date:

Creates and returns a text checking result as a result of locating a date.

+ (NSTextCheckingResult *)dateCheckingResultWithRange:(NSRange)rangedate:(NSDate *)date

Parameters
range

The range of the detected result.

date

The detected date.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeDate.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

dateCheckingResultWithRange:date:timeZone:duration:

Creates and returns a text checking result as a result of locating a date.

+ (NSTextCheckingResult *)dateCheckingResultWithRange:(NSRange)rangedate:(NSDate *)datetimeZone:(NSTimeZone *)timeZoneduration:(NSTimeInterval)duration

Parameters
range

The range of the detected result.

date

The detected date.

timeZone

The detected time zone.

duration

The detected duration.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeDate.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

grammarCheckingResultWithRange:details:

Creates and returns a text checking result after a grammar error.

+ (NSTextCheckingResult *)grammarCheckingResultWithRange:(NSRange)range details:(NSArray *)details

Parameters
range

The range of the detected result.

details

An array of details regarding the grammatical errors. This array of strings is suitable for presenting to the user.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeGrammar.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

linkCheckingResultWithRange:URL:

Creates and returns a text checking result after locating a URL link.

+ (NSTextCheckingResult *)linkCheckingResultWithRange:(NSRange)rangeURL:(NSURL *)url

Parameters
range

The range of the detected result.

url

The detected URL.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeLink.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

orthographyCheckingResultWithRange:orthography:

Creates and returns a text checking result after locating a language script.

+ (NSTextCheckingResult *)orthographyCheckingResultWithRange:(NSRange)range orthography:(NSOrthography *)orthography

Parameters
range

The range of the detected result.

orthography

An orthograhy object that describes the script.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeOrthography.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

quoteCheckingResultWithRange:replacementString:

Creates and returns a text checking result after locating unbalanced quotes.

+ (NSTextCheckingResult *)quoteCheckingResultWithRange:(NSRange)range replacementString:(NSString *)replacementString

Parameters
range

The range of the detected result.

replacementString

The replacement string.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeQuote.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

replacementCheckingResultWithRange:replacementString:

Creates and returns a text checking result after locating a string that requires replacement.

+ (NSTextCheckingResult *)replacementCheckingResultWithRange:(NSRange)rangereplacementString:(NSString *)replacementString

Parameters
range

The range of the detected result.

replacementString

The replacement string.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeReplacement.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

spellCheckingResultWithRange:

Creates and returns a text checking result after locating a misspelled word.

+ (NSTextCheckingResult *)spellCheckingResultWithRange:(NSRange)range

Parameters
range

The range of the detected result.

Return Value

Returns an NSTextCheckingResult with the specified range and a resultType of NSTextCheckingTypeSpelling.

Availability
  • Available in Mac OS X v10.6 and later.
Declared In
NSTextCheckingResult.h

Constants

Keys for Address Components

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

NSString * const NSTextCheckingNameKey;
NSString * const NSTextCheckingJobTitleKey;
NSString * const NSTextCheckingOrganizationKey;
NSString * const NSTextCheckingStreetKey;
NSString * const NSTextCheckingCityKey;
NSString * const NSTextCheckingStateKey;
NSString * const NSTextCheckingZIPKey;
NSString * const NSTextCheckingCountryKey;
NSString * const NSTextCheckingPhoneKey;
Constants
NSTextCheckingNameKey

A key that corresponds to the name component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingJobTitleKey

A key that corresponds to the job component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingOrganizationKey

A key that corresponds to the organization component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingStreetKey

A key that corresponds to the street address component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingCityKey

A key that corresponds to the city component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingStateKey

A key that corresponds to the state or province component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingZIPKey

A key that corresponds to the zip code or postal code component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingCountryKey

A key that corresponds to the country component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingPhoneKey

A key that corresponds to the phone number component of the address.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingType

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

enum {
   NSTextCheckingTypeOrthography   = 1ULL << 0,
   NSTextCheckingTypeSpelling      = 1ULL << 1,
   NSTextCheckingTypeGrammar       = 1ULL << 2,
   NSTextCheckingTypeDate          = 1ULL << 3,
   NSTextCheckingTypeAddress       = 1ULL << 4,
   NSTextCheckingTypeLink          = 1ULL << 5,
   NSTextCheckingTypeQuote         = 1ULL << 6,
   NSTextCheckingTypeDash          = 1ULL << 7,
   NSTextCheckingTypeReplacement   = 1ULL << 8,
   NSTextCheckingTypeCorrection    = 1ULL << 9
};
typedef uint64_t NSTextCheckingType;
Constants
NSTextCheckingTypeOrthography

Attempts to identify the language

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeSpelling

Checks spelling.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeGrammar

Checks grammar.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeDate

Attempts to locate dates.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeAddress

Attempts to locate addresses.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeLink

Attempts to locate URL links.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeQuote

Replaces quotes with smart quotes..

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeDash

Replaces dashes with em-dashes.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeReplacement

Replaces characters such as (c) with the appropriate symbol (in this case ©).

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypeCorrection

Performs autocorrection on misspelled words.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingTypes

Defines the types of checking that are available. The system supports its own internal types, and the user can extend those types by subclassing NSTextCheckingResult and adding their own custom types.

enum {
   NSTextCheckingAllSystemTypes    = 0xffffffffULL,
   NSTextCheckingAllCustomTypes    = 0xffffffffULL << 32,
purposes
   NSTextCheckingAllTypes          = (NSTextCheckingAllSystemTypes | NSTextCheckingAllCustomTypes)
};
typedef uint64_t NSTextCheckingTypes;
Constants
NSTextCheckingAllSystemTypes

Checking types supported by the system. The first 32 types are reserved.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingAllCustomTypes

Checking types that can be used by clients.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.

NSTextCheckingAllTypes

All possible checking types, both system and user supported.

Available in Mac OS X v10.6 and later.

Declared in NSTextCheckingResult.h.




Last updated: 2009-07-08

Did this document help you? Yes It's good, but... Not helpful...