Rich Objects
One of the most useful features of Cocoa is the powerful "base objects" the system supplies. As an example, consider the Foundation classes NSString
and NSAttributedString
, which provide Unicode strings, and the NSText
system in AppKit, which allows the programmer to place string objects in the GUI.
NSText
and its related classes are used to display and edit strings. The collection of objects involved permit an application to implement anything from a simple single-line text entry field to a complete multi-page, multi-column text layout schema, with full professional typography features such as kerning, ligatures, running text around arbitrary shapes, rotation, full Unicode support and anti-aliased glyph rendering. Paragraph layout can be controlled automatically or by the user, using a built-in "ruler" object that can be attached to any text view. Spell checking is automatic, using a single dictionary used by all applications that uses the "squiggly underlining" convention introduced by Microsoft (actually a dashed red underline in Cocoa). Unlimited Undo/Redo support is built in. Using only the built-in features, one can write a text editor application in as few as 10 lines of code. With new controller objects, this may fall to zero. This is in contrast to the TextEdit APIs found in the earlier Mac OS.
When extensions are needed, Cocoa's use of Objective-C makes this a straightforward task. Objective-C includes the concept of "categories" which allows for modifications to an existing class "in-place". Functionality can be accomplished in a category without any changes to the original classes in the framework, or even access to its source. Under more common frameworks this same task would require the programmer to make a new subclass supporting the additional features, and then change all instances of the classes to this new class.
Read more about this topic: Cocoa (API)
Famous quotes containing the words rich and/or objects:
“Injurious Time now, with a robbers haste,
Crams his rich thievery up, he knows not how;
As many farewells as be stars in heaven,
With distinct breath and consigned kisses to them,
He fumbles up into a loose adieu,
And scants us with a single famished kiss,
Distasted with the salt of broken tears.”
—William Shakespeare (15641616)
“It is an inexpressible Pleasure to know a little of the World, and be of no Character or Significancy in it. To be ever unconcerned, and ever looking on new Objects with an endless Curiosity, is a Delight known only to those who are turned for Speculation: Nay, they who enjoy it, must value things only as they are the Objects of Speculation, without drawing any worldly Advantage to themselves from them, but just as they are what contribute to their Amusement, or the Improvement of the Mind.”
—Richard Steele (16721729)