PDF Cocoa in A Nutshell A Desktop Quick Reference 1st Edition Michael Beam Download
PDF Cocoa in A Nutshell A Desktop Quick Reference 1st Edition Michael Beam Download
com
https://ebookname.com/product/cocoa-in-a-nutshell-a-desktop-
quick-reference-1st-edition-michael-beam/
OR CLICK HERE
DOWLOAD NOW
https://ebookname.com/product/python-in-a-nutshell-a-desktop-quick-
reference-3rd-edition-edition-alex-martelli/
ebookname.com
https://ebookname.com/product/linux-in-a-nutshell-a-desktop-quick-
reference-6th-ed-edition-ellen-siever/
ebookname.com
https://ebookname.com/product/applescript-in-a-nutshell-a-desktop-
quick-reference-1st-ed-edition-bruce-w-perry/
ebookname.com
https://ebookname.com/product/march-to-the-west-the-german-invasion-
of-france-the-low-countries-1st-edition-gordon-l-rottman/
ebookname.com
https://ebookname.com/product/the-anatomy-and-biology-of-the-human-
skeleton-7th-revised-reprint-edition-d-gentry-steele/
ebookname.com
https://ebookname.com/product/planning-the-new-suburbia-flexibility-
by-design-1st-edition-avi-friedman/
ebookname.com
https://ebookname.com/product/the-art-of-comparison-how-novels-and-
critics-compare-1st-edition-catherine-brown/
ebookname.com
https://ebookname.com/product/gene-transfer-to-animal-cells-advanced-
methods-1st-edition-r-m-twyman/
ebookname.com
The Chemistry Of Radical Polymerization 2nd Edition Graeme
Moad
https://ebookname.com/product/the-chemistry-of-radical-
polymerization-2nd-edition-graeme-moad/
ebookname.com
[ Team LiB ]
• Table of Contents
• Index
• Reviews
• Reader Reviews
• Errata
Cocoa in a Nutshell
Publisher: O'Reilly
Date
: May 2003
Published
ISBN: 0-596-00462-1
Pages: 566
Cocoa in a Nutshell begins with a complete overview of Cocoa's object classes. It provides developers
who may be experienced with other application toolkits the grounding they'll need to start developing
Cocoa applications. A complement to Apple's documentation, it is the only reference to the classes,
functions, types, constants, protocols, and methods that make up Cocoa's Foundation and Application
Kit frameworks, based on the Jaguar release (Mac OS X 10.2).
[ Team LiB ]
[ Team LiB ]
• Table of Contents
• Index
• Reviews
• Reader Reviews
• Errata
Cocoa in a Nutshell
Publisher: O'Reilly
Date
: May 2003
Published
ISBN: 0-596-00462-1
Pages: 566
Copyright
Preface
What Is Cocoa?
How This Book Is Organized
Conventions Used in This Book
How the Quick Reference Was Generated
Comments and Questions
Acknowledgments
Chapter 2. Foundation
Section 2.1. Data
Section 2.2. Key-Value Coding
Section 2.3. Working with Files
Section 2.4. Bundles and Resource Management
Section 2.5. Archiving Objects
Section 2.6. User Defaults
Section 2.7. Notifications
Section 2.8. Operating System Interaction
Section 2.9. Threaded Programming
Chapter 6. Networking
Section 6.1. Hosts
Section 6.2. URL Resources
Section 6.3. Rendezvous Network Services
Section 6.4. Sockets
Section 6.5. NSFileHandle
Method Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
XYZ
Colophon
Index
[ Team LiB ]
[ Team LiB ]
Published by O'Reilly & Associates, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O'Reilly & Associates books may be purchased for educational, business, or sales promotional use.
Online editions are also available for most titles (http://safari.oreilly.com). For more information,
contact our corporate/institutional sales department: (800) 998-9938 or [email protected].
Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of
O'Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish
their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly
& Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or
initial caps. The association between the image of an Irish setter and the topic of Cocoa is a trademark
of O'Reilly & Associates, Inc.
Apple Computer, Inc. boldly combined open source technologies with its own programming efforts to
create Mac OS X, one of the most versatile and stable operating systems now available. In the same
spirit, Apple has joined forces with O'Reilly & Associates to bring you an indispensable collection of
technical publications. The ADC logo indicates that the book has been technically reviewed by Apple
engineers and is recommended by the Apple Developer Connection.
Apple, the Apple logo, AppleScript, AppleTalk, AppleWorks, Carbon, Cocoa, ColorSync, Finder,
FireWire, iBook, iMac, iPod, Mac, Mac logo, Macintosh, PowerBook, QuickTime, QuickTime logo,
Sherlock, and WebObjects are trademarks of Apple Computer, Inc., registered in the United States
and other countries. The "keyboard" Apple logo ( ) is used with permission of Apple Computer, Inc.
While every precaution has been taken in the preparation of this book, the publisher and authors
assume no responsibility for errors or omissions, or for damages resulting from the use of the
information contained herein.
[ Team LiB ]
[ Team LiB ]
Preface
It's practically impossible to know Cocoa inside and out. There was once a discussion between two
programmers about Cocoa's large APIs: one was a veteran Perl programmer, the other a Cocoa
programmer. The Perl programmer grumbled about the intimidating and verbose Cocoa APIs, saying
there was simply too much to remember. Bemused, the Cocoa programmer retorted: "You don't
remember Cocoa; you look it up!"
The point the Cocoa programmer was trying to impress upon the Perl programmer was that
understanding object-oriented programming (OOP) concepts and the architecture of the frameworks is
more important than remembering the wordy and numerous method and class names in the Cocoa
frameworks.
This book is a compact reference that will hopefully grow worn beside your keyboard. Split into two
parts, Cocoa in a Nutshell first provides an overview of the frameworks that focuses on both common
programming tasks and how the parts of the framework interact with one another. The second part of
the book is an API quick reference that frees you from having to remember method and class names
so you can spend more time hacking code. This book covers the Cocoa frameworks—Foundation and
Application Kit (AppKit)—as of Mac OS X 10.2 (Jaguar).
[ Team LiB ]
[ Team LiB ]
What Is Cocoa?
Cocoa is a complete set of classes and application programming interfaces (APIs) for building Mac OS
X applications and tools. With over 240 classes, Cocoa is divided into two essential frameworks: the
Foundation framework and the Application Kit.
The Foundation framework provides a fundamental set of tools for representing fundamental data
types, accessing operating system services, threading, messaging, and more. The Application Kit
provides the functionality to build graphical user interfaces (GUI) for Cocoa applications. It provides
access to the standard Aqua interface components ranging from menus, buttons, and text fields—the
building blocks of larger interfaces—to complete, prepackaged interfaces for print dialogs, file
operation dialogs, and alert dialogs. The Application Kit also provides higher-level functionality to
implement multiple document applications, text handling, and graphics.
Classes are not the only constituents of the Cocoa frameworks. Some programming tasks, such as
sounding a system beep, are best accomplished with a simple C function. Cocoa includes a number of
functions for accomplishing tasks such as manipulating byte orders and drawing simple graphics.
Additionally, Cocoa defines a number of custom data types and constants to provide a higher degree
of abstraction to many method parameters.
Interface Builder is used to create GUIs for Cocoa applications by allowing developers to manipulate UI
components (such as windows and buttons) graphically using drag and drop. It provides assistance for
laying out components by providing visual cues that conform to Apple's Aqua Human Interface
Guidelines. From an inspector panel, the behavior and appearance of these components can be
tweaked in almost every way the component supports. Interface Builder provides an intuitive way to
connect objects by letting the user drag wires between objects. This way, you set up the initial
network of objects in the interface. In addition, you can interface without having to compile a single bit
of code.
Interface components are not the only objects that can be manipulated with Interface Builder. You can
subclass any Cocoa class and create instances of the subclasses. More importantly, you can give these
classes instance variables, known as outlets, and methods, called actions, and hook them up to user
interface components. Interface Builder can then create source files for these subclasses, complete
header files, and an implementation file including stubs for the action methods. There is much more to
Interface Builder and Project Builder than we can cover in this book, but as you can begin to imagine,
the tight integration of these two applications create a compelling application development
environment.
In this pattern, one object, the delegate, acts on behalf of another object. Delegation is used to
alter the behavior of an object that takes a delegate. The developer's job is to implement any
number of methods that may be invoked in the delegate. Delegation minimizes the need to
subclass objects to extend their functionality.
Singleton
This pattern ensures that only one object instance of a class exists in the system. A singleton
method is an object constructor that creates an instance of the class and maintains a reference
to that object. Subsequent invocations of the singleton constructor return the existing object,
rather than create a new one.
Notification
Notifications allow decoupling of message senders from multiple message receivers. Cocoa
implements this pattern in the notification system used throughout the frameworks. It is
discussed in Chapter 2.
Model-View-Control
The Model-View-Controller (MVC) pattern is used extensively in the Application Kit to separate
an application into logically distinct units: a model, which knows how to work with application
data, the view, which is responsible for presenting the data to the user, and the controller,
which handles interaction between the model and the view. Chapter 3 discusses MVC in more
detail.
Target/action
The target/action pattern decouples user-interface components, such as buttons and menu
items, with the objects (the targets) that implement their actions. In this pattern, an activated
control sends an action message to its target. Chapter 3 discusses this topic further.
Responder chain
The responder chain pattern is used in the event handling system to give multiple objects a
chance to respond to an event. This topic is discussed in Chapter 3.
Key-value coding
Key-value coding provides an interface for accessing an object's properties indirectly by name.
Chapter 2 covers key-value coding more thoroughly.
Benefits
These days, application developers expect a lot from their tools, and users expect a lot from any
application they use. Any application or application toolkit that neglects these needs is destined for
failure. Cocoa comes through grandly by providing the features needed in applications now and in the
future, including:
Framework-based development
Cocoa development is based on its frameworks: the Foundation framework and the Application
Kit. With framework-based programming, the system takes a central role in the life of an
application by calling out to code that you provide. This role allows the frameworks to take care
of an application's behind-the-scene details and lets you focus on providing the functionality that
makes your application unique.
"For free" features
Cocoa provides a lot of standard application functionality "for free" as part of the frameworks.
These features not only include the large number of user-interface components, but larger
application subsystems such as the text-handling system and the document-based application
architecture. Because Apple has gone to great lengths to provide these features as a part of
Cocoa, developers can spend less time doing the repetitive work that is common between all
applications, and more time adding unique value to their application.
The development environment
As discussed earlier, Project Builder and Interface Builder provide a development environment
that is highly integrated with the Cocoa frameworks. Interface Builder is used to quickly build
user interfaces, which means less tedious work for the developer.
Cocoa's most important benefit is that it lets you develop applications dramatically faster than with
other application frameworks.
Languages
Cocoa's native language is Objective-C. The Foundation and Application Kit frameworks are
implemented in Objective-C, and using Objective-C provides access to all features of the frameworks.
Chapter 1 covers Objective-C in depth.
Objective-C is not, however, the only language through which you can access the Cocoa frameworks.
Through the Java Bridge, Apple provides a way to access the Cocoa frameworks using the Java
language. The Java Bridge does not provide a complete solution since many of Cocoa's advanced
features, such as the distributed objects system, are not available with Java. This book will not discuss
Cocoa application development with Java.
Another option for working with Cocoa is AppleScript. AppleScript has traditionally been associated
with simple scripting tasks, but with Mac OS X, Apple enabled AppleScript access to the Cocoa
frameworks via AppleScript Studio. AppleScript Studio provides hooks into the Cocoa API so scripters
can take their existing knowledge of AppleScript, write an application in Project Builder, and use
Interface Builder to give their applications an Aqua interface—all without having to learn Objective-C.
This exposes Cocoa to a completely new base of Macintosh developers, who know enough AppleScript
to build simple task-driven applications for solving common problems. For more information about
AppleScript Studio, see http://www.apple.com/applescript/studio.
[ Team LiB ]
Random documents with unrelated
content Scribd suggests to you:
the sense of a moved understanding, had always been lacking. “But then,”
she added ingenuously, “I’ve never really been sure, because I’ve never told
anyone my story. Only I take it for granted that, if I haven’t, it’s their fault
rather than mine....” She smiled half-deprecatingly, and my bosom swelled,
acknowledging the distinction. “And now I want to tell you—” she began.
I have said that my love for Mrs. Hazeldean was a brief episode in our
long relation. At my age, it was inevitable that it should be so. The “fresher
face” soon came, and in its light I saw my old friend as a middle-aged
woman, turning grey, with a mechanical smile and haunted eyes. But it was
in the first glow of my feeling that she had told me her story; and when the
glow subsided, and in the afternoon light of a long intimacy I judged and
tested her statements, I found that each detail fitted into the earlier picture.
My opportunities were many; for once she had told the tale she always
wanted to be retelling it. A perpetual longing to relive the past, a perpetual
need to explain and justify herself—the satisfaction of these two cravings,
once she had permitted herself to indulge them, became the luxury of her
empty life. She had kept it empty—emotionally, sentimentally empty—
from the day of her husband’s death, as the guardian of an abandoned
temple might go on forever sweeping and tending what had once been the
god’s abode. But this duty performed, she had no other. She had done one
great—or abominable—thing; rank it as you please, it had been done
heroically. But there was nothing in her to keep her at that height. Her
tastes, her interests, her conceivable occupations, were all on the level of a
middling domesticity; she did not know how to create for herself any inner
life in keeping with that one unprecedented impulse.
Soon after her husband’s death, one of her cousins, the Miss Cecilia
Winter of Washington Square to whom my mother had referred, had died
also, and left Mrs. Hazeldean a handsome legacy. And a year or two later
Charles Hazeldean’s small estate had undergone the favourable change that
befell New York realty in the ’eighties. The property he had bequeathed to
his wife had doubled, then tripled, in value; and she found herself, after a
few years of widowhood, in possession of an income large enough to
supply her with all the luxuries which her husband had struggled so hard to
provide. It was the peculiar irony of her lot to be secured from temptation
when all danger of temptation was over; for she would never, I am certain,
have held out the tip of her finger to any man to obtain such luxuries for her
own enjoyment. But if she did not value her money for itself, she owed to it
—and the service was perhaps greater than she was aware—the power of
mitigating her solitude, and filling it with the trivial distractions without
which she was less and less able to live.
She had been put into the world, apparently, to amuse men and enchant
them; yet, her husband dead, her sacrifice accomplished, she would have
preferred, I am sure, to shut herself up in a lonely monumental attitude,
with thoughts and pursuits on a scale with her one great hour. But what was
she to do? She had known of no way of earning money except by her
graces; and now she knew no way of filling her days except with cards and
chatter and theatre-going. Not one of the men who approached her passed
beyond the friendly barrier she had opposed to me. Of that I was sure. She
had not shut out Henry Prest in order to replace him—her face grew white
at the suggestion. But what else was there to do, she asked me; what? The
days had to be spent somehow; and she was incurably, disconsolately
sociable.
So she lived, in a cold celibacy that passed for I don’t know what
licence; so she lived, withdrawn from us all, yet needing us so desperately,
inwardly faithful to her one high impulse, yet so incapable of attuning her
daily behaviour to it! And so, at the very moment when she ceased to
deserve the blame of society, she found herself cut off from it, and reduced
to the status of the “fast” widow noted for her jolly suppers.
I bent bewildered over the depths of her plight. What else, at any stage of
her career, could she have done, I often wondered? Among the young
women now growing up about me I find none with enough imagination to
picture the helpless incapacity of the pretty girl of the ’seventies, the girl
without money or vocation, seemingly put into the world only to please,
and unlearned in any way of maintaining herself there by her own efforts.
Marriage alone could save such a girl from starvation, unless she happened
to run across an old lady who wanted her dogs exercised and her
Churchman read aloud to her. Even the day of painting wild-roses on fans,
of colouring photographs to “look like” miniatures, of manufacturing lamp-
shades and trimming hats for more fortunate friends—even this precarious
beginning of feminine independence had not dawned. It was inconceivable
to my mother’s generation that a portionless girl should not be provided for
by her relations until she found a husband; and that, having found him, she
should have to help him to earn a living, was more inconceivable still. The
self-sufficing little society of that vanished New York attached no great
importance to wealth, but regarded poverty as so distasteful that it simply
took no account of it.
These things pleaded in favour of poor Lizzie Hazeldean, though to
superficial observers her daily life seemed to belie the plea. She had known
no way of smoothing her husband’s last years but by being false to him; but
once he was dead, she expiated her betrayal by a rigidity of conduct for
which she asked no reward but her own inner satisfaction. As she grew
older, and her friends scattered, married, or were kept away from one cause
or another, she filled her depleted circle with a less fastidious hand. One
met in her drawing-room dull men, common men, men who too obviously
came there because they were not invited elsewhere, and hoped to use her
as a social stepping-stone. She was aware of the difference—her eyes said
so whenever I found one of these newcomers installed in my arm-chair—
but never, by word or sign, did she admit it. She said to me once: “You find
it duller here than it used to be. It’s my fault, perhaps; I think I knew better
how to draw out my old friends.” And another day: “Remember, the people
you meet here now come out of kindness. I’m an old woman, and I consider
nothing else.” That was all.
She went more assiduously than ever to the theatre and the opera; she
performed for her friends a hundred trivial services; in her eagerness to be
always busy she invented superfluous attentions, oppressed people by
offering assistance they did not need, verged at times—for all her tact—on
the officiousness of the desperately lonely. At her little suppers she
surprised us with exquisite flowers and novel delicacies. The champagne
and cigars grew better and better as the quality of the guests declined; and
sometimes, as the last of her dull company dispersed, I used to see her,
among the scattered ash-trays and liqueur decanters, turn a stealthy glance
at her reflection in the mirror, with haggard eyes which seemed to ask:
“Will even these come back tomorrow?”
I should be loth to leave the picture at this point; my last vision of her is
more satisfying. I had been away, travelling for a year at the other end of
the world; the day I came back I ran across Hubert Wesson at my club.
Hubert had grown pompous and heavy. He drew me into a corner, and said,
turning red, and glancing cautiously over his shoulder: “Have you seen our
old friend Mrs. Hazeldean? She’s very ill, I hear.”
I was about to take up the “I hear”; then I remembered that in my
absence Hubert had married, and that his caution was probably a tribute to
his new state. I hurried at once to Mrs. Hazeldean’s; and on her door-step,
to my surprise, I ran against a Catholic priest, who looked gravely at me,
bowed and passed out.
I was unprepared for such an encounter, for my old friend had never
spoken to me of religious matters. The spectacle of her father’s career had
presumably shaken whatever incipient faith was in her; though in her little-
girlhood, as she often told me, she had been as deeply impressed by Dr.
Winter’s eloquence as any grown-up member of his flock. But now, as soon
as I laid eyes on her, I understood. She was very ill, she was visibly dying;
and in her extremity, fate, not always kind, had sent her the solace which
she needed. Had some obscure inheritance of religious feeling awaked in
her? Had she remembered that her poor father, after his long life of mental
and moral vagabondage, had finally found rest in the ancient fold? I never
knew the explanation—she probably never knew it herself.
But she knew that she had found what she wanted. At last she could talk
of Charles, she could confess her sin, she could be absolved of it. Since
cards and suppers and chatter were over, what more blessed barrier could
she find against solitude? All her life, henceforth, was a long preparation for
that daily hour of expansion and consolation. And then this merciful visitor,
who understood her so well, could also tell her things about Charles: knew
where he was, how he felt, what exquisite daily attentions could still be paid
to him, and how, with all unworthiness washed away, she might at last hope
to reach him. Heaven could never seem strange, so interpreted; each time
that I saw her, during the weeks of her slow fading, she was more and more
like a traveller with her face turned homeward, yet smilingly resigned to
await her summons. The house no longer seemed lonely, nor the hours
tedious; there had even been found for her, among the books she had so
often tried to read, those books which had long looked at her with such
hostile faces, two or three (they were always on her bed) containing
messages from the world where Charles was waiting.
Thus provided and led, one day she went to him.
THE END
*** END OF THE PROJECT GUTENBERG EBOOK NEW YEAR'S DAY
(THE 'SEVENTIES) ***
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com