I want to add a data detector in an NSTextField / NSTextView like in Mail (e.g. date, email, URL, etc).
Does anyone have an idea how to do this ? I think I saw it in
In Snow Leopard you can now enable Data Detectors in a NSTextView by simply clicking the appropriate checkbox in the IB inspector.
You need to set the formatter outlet of the object. Built in formatters are NSDateFormatter and NSNumberFormatter.
You can define custom formatters by extending the NSFormatter class. There is a chapter in Aaron Hillegass excellent 'Cocoa Programming for Max OS X' on Creating NSFormatters.
To detect dates, url, email address, etc. within the body of some text, you can use the Latent Semantic Mapping Framework. It's a public API as of Leopard but there isn't a great deal of documentation for it. There is also a command line tool called lsm that would allow you to test any custom extractors you want to use. It is a C API and not integrated into Cocoa as far as I know so you'd need to wire it up yourself