I am trying to port some Obj-c code and have problems creating NSDataDetector.
In Objective-C, I would do the following:
NSDataDetector *linkDetector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil];
From the documentation I have to do this:
let linkDetector = NSDataDetector.dataDetectorWithTypes(NSTextCheckingType.Link, error: &error)
But I get a compiler error: "NSTextCheckingType" does not convert to "NStextCheckingTypes"
If try this:
let linkDetector = NSDataDetector.dataDetectorWithTypes(NSTextCheckingTypes(), error: &gError)
However, it passes, I get an exception at runtime:
[NSDataDetector initWithTypes:error:]: no data detector types specified'
Not sure if this is a mistake or not.
Thanks.
swift
Miguelb
source share