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:
“We had to take the world as it was given:
The nursemaid sitting passive in the park
Was rarely by a changeling prince accosted,
The mornings happened similar and stark
In rooms of selfhood where we woke and lay
Watching today unfold like yesterday.”
—Adrienne Rich (b. 1929)
“The cart before the horse is neither beautiful nor useful. Before we can adorn our houses with beautiful objects the walls must be stripped, and our lives must be stripped, and beautiful housekeeping and beautiful living laid for a foundation.”
—Henry David Thoreau (18171862)