Skip to content

Extensions to make the NSDataDetector more pleasant to work with.

License

Notifications You must be signed in to change notification settings

nemecek-filip/SwiftyDataDetector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

SwiftyDataDetector

My attempt to use extensions and custom data types to make working with NSDataDetector more Swifty and pleasant. I have written a blog post about this.

For example you can construct it like this:

let detector = NSDataDetector(dataTypes: DataDetectorType.allCases)

And here is an example of using my enumerateMatches method:

detector.enumerateMatches(in: exampleText) { (range, match) in
    switch match {
    case .email(let email, let mailtoURL):
        print("Found email address: \(email)")
    case .phoneNumber(let number):
        print("Found phone number: \(number)")
    default:
        break
    }
}

About

Extensions to make the NSDataDetector more pleasant to work with.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages