Inherits from NSObject
Conforms to CPTokenRecogniser
Declared in CPNumberRecogniser.h
CPNumberRecogniser.m

Overview

The CPNumberRecogniser class attempts to recognise integers and floating point numbers in the input string.

Number recognisers can be set up to recognise only integers, only floating point numbers, or both.

This recogniser produces CPNumberTokens.

Tasks

Creating and Initialising a Number Recogniser

Configuring a Number Recogniser

  •   recognisesInts

    Specifies whether the recogniser should recognise integers.

    property
  •   recognisesFloats

    Specifies whether the recogniser should recognise floating point numbers.

    property

Other Methods

Properties

recognisesFloats

Specifies whether the recogniser should recognise floating point numbers.

@property (readwrite, assign) BOOL recognisesFloats

Discussion

Specifies whether the recogniser should recognise floating point numbers.

Declared In

CPNumberRecogniser.h

recognisesInts

Specifies whether the recogniser should recognise integers.

@property (readwrite, assign) BOOL recognisesInts

Discussion

Specifies whether the recogniser should recognise integers.

Declared In

CPNumberRecogniser.h

Class Methods

floatRecogniser

Creates a number recogniser that recognises only floating point numbers.

+ (id)floatRecogniser

Return Value

Returns a CPNumberRecogniser that recognises only floating point numbers.

Discussion

Creates a number recogniser that recognises only floating point numbers.

Declared In

CPNumberRecogniser.h

integerRecogniser

Creates a number recogniser that recognises only integers.

+ (id)integerRecogniser

Return Value

Returns a CPNumberRecogniser that recognises only integers.

Discussion

Creates a number recogniser that recognises only integers.

Declared In

CPNumberRecogniser.h

numberRecogniser

Creates a number recogniser that recognises both integers and floating point numbers.

+ (id)numberRecogniser

Return Value

Returns a CPNumberRecogniser that recognises both integers and floating point numbers.

Discussion

Creates a number recogniser that recognises both integers and floating point numbers.

Declared In

CPNumberRecogniser.h

Instance Methods

recogniseTokenInString:currentTokenPosition:

Attempts to recognise a token at tokenPosition in tokenString.

- (CPToken *)recogniseTokenInString:(NSString *)tokenString currentTokenPosition:(NSUInteger *)tokenPosition

Parameters

tokenString

The string in which to recognise tokens.

tokenPosition

The position at which to try to find the token. On output, the position after the recognised token.

Return Value

Returns the token recognised.

Discussion

Attempts to recognise a token at tokenPosition in tokenString.

If a token is successfully recognised, it should be returned, and tokenPosition advanced to after the consumed characters. If no valid token is found nil must be returned instead, and tokenPosition left unchanged.

Declared In

CPTokenRecogniser.h