---
title: "init(types:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsdatadetector/init(types:)"
---

# init(types:)

Initializes and returns a data detector instance.

## Declaration

```swift
init(types checkingTypes: NSTextCheckingTypes) throws
```

## Parameters

- `checkingTypes`: The checking types. The supported checking types are a subset of the types doc://com.apple.foundation/documentation/Foundation/NSTextCheckingResult/CheckingType. Those constants can be combined using the C-bitwise OR operator.

## Return Value

Return Value Returns the newly initialized data detector. If an error was encountered returns nil, and error contains the error.

## Discussion

Discussion Currently, the supported data detectors checkingTypes are:  date, address, link, NSTextCheckingTypePhoneNumber, and NSTextCheckingTypeTransitInformation. note: In Swift, this API is imported as an initializer and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Related Documentation

- [checkingTypes](foundation/nsdatadetector/checkingtypes.md)
