O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

WordCounter

Figure 22.6 shows a program that counts the number of words in a text field as well as the number of unique words. Text fields are updated with the values.

Figure 22.6  WordCounter screenshot

WordCounter screenshot

The code for this application is straightforward. In Xcode, make a new Cocoa Application (not document-based) called WordCounter. Add the objects seen in Figure 22.6: an NSTextView, a count button, a progress indicator, and two labels for the different counts. Configure your object layout appropriately. Update your AppDelegate class to point to the UI items, as well as the -count: action method:

#​i​m​p​o​r​t​ ​<​C​o​c​o​a​/​C​o​c​o​a​.​h​>​ @​i​n​t​e​r​f​a​c​e​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required