How to add line numbers in a NSTextView ?

I need to display line numbers in NSTextView of my own...
Some examples are available on the Net: from Koen Van Der Drift
from
Masatoshi Nishikata
from
James S. Derry
from
Smultron on SourceForge