Cocoa in A Nutshell A Desktop Quick Reference 1st Edition Michael Beam - The 2025 Ebook Edition Is Available With Updated Content
Cocoa in A Nutshell A Desktop Quick Reference 1st Edition Michael Beam - The 2025 Ebook Edition Is Available With Updated Content
com
https://ebookname.com/product/cocoa-in-a-nutshell-a-desktop-
quick-reference-1st-edition-michael-beam/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookname.com/product/python-in-a-nutshell-a-desktop-
quick-reference-3rd-edition-edition-alex-martelli/
https://ebookname.com/product/linux-in-a-nutshell-a-desktop-
quick-reference-6th-ed-edition-ellen-siever/
https://ebookname.com/product/applescript-in-a-nutshell-a-
desktop-quick-reference-1st-ed-edition-bruce-w-perry/
https://ebookname.com/product/atlas-of-laparoscopy-and-
hysteroscopy-techniques-third-edition-togas-tulandi/
The Christian as Minister An Exploration Into the
Meaning of God s Calling 1st Edition Lassiat Meg
https://ebookname.com/product/the-christian-as-minister-an-
exploration-into-the-meaning-of-god-s-calling-1st-edition-
lassiat-meg/
https://ebookname.com/product/emergent-phenomena-in-housing-
markets-gentrification-housing-search-polarization-1st-edition-
lidia-diappi-auth/
https://ebookname.com/product/fish-parasites-pathobiology-and-
protection-1st-edition-patrick-t-k-woo/
https://ebookname.com/product/briefs-of-leading-cases-in-
corrections-fifth-edition-rolando-v-del-carmen/
https://ebookname.com/product/managing-money-for-general-
practitioners-2nd-edition-mike-gilbert/
A Catholic Introduction to the Bible The Old Testament
Brant Pitre
https://ebookname.com/product/a-catholic-introduction-to-the-
bible-the-old-testament-brant-pitre/
[ 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 ]
Other documents randomly have
different content
The Project Gutenberg eBook of The Brain
Sinner
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: English
The skin tone was wrong. The yellow came through too clearly in
places, and in this strange culture that color was reported to carry
unpleasant connotations. He worked pale, sickly-pink stuff into his
soft, wrinkle-free skin, then molded out the cheeks and forehead.
Hair would be a problem, of course, but then there would be many
small imperfections. He smiled grimly to himself. There were other
ways of masking imperfections.
At last he was satisfied. There was no way to bring the normal
reddish color into the pale green lips; there was no way to
satisfactorily prepare the myriad wrinkles and creases that crossed
the skin of the man-things, but with a little skillful application of
projection techniques it did not matter.
The alien struggled into the tight, restricting clothes that lay in a
bundle, carefully folded and pressed, at his feet. The hard, board-
like shoes cut at his ankles, and the hairy stuff of the red-and-white
checked shirt made him writhe in discomfort, but once outside the
ship he was glad for the warmth. He stepped out onto the ground,
and listened again carefully. Then he made certain arrangements
with wires, and threw a switch on a small black case near the air
lock, and began marching down the hill away from the ship.
He would no longer need the ship. Not now.
The underbrush grew thicker, and he fought his way through the
scrub until he reached a roadway. It was not paved. A flicker of sour
amusement swept through the alien's mind. They had been afraid
that these simple creatures might try to oppose them! Yet the scouts
had said that far to the East were great stone and steel cities—the
places-of-madness, the scout had said. Perhaps. But here there was
no stone and steel, only dust, and the ruts of wagon wheels, and a
howling dog somewhere over the hill.
The alien trudged on for almost an hour, trying to acclimate his legs
to the fierce tug of gravity that pulled at him. And then he stopped
short and listened.
He heard them, then, in the depths of his mind, somewhere on the
other side of the hill. His eyes narrowed. No psi-presence there, but
two of the man-things, beyond doubt. Other whispers, too dull,
stupid, vagrant whispers flickering through his mind. Lower life
forms, no doubt. Possibly a farm with work animals. The scouts had
said there were such. He turned off the road and almost cried out
when the sharp barbs of a fence cut through his tender skin.
A trickle of green dripped down his arm, until he rubbed a poultice
across it, and it became smooth and sickly-pink again. With a vicious
jerk he pulled the fence out, post and all, and left it on the ground,
moving through the woods toward the sounds he had heard.
Soon the woods ended and he saw the dwelling across a broad
clearing. Black dirt lay open in the moonlight. He started across.
There was light inside the dwelling, and the dull, babbling flow of
uncontrolled man-thought struck his mind like a vapor. There were
other buildings, too, dark buildings, and one tall one that had a
spoked wheel on top, and creaked and rustled in the darkness.
He had almost reached the dwelling when a small, four-legged
creature jumped up in the darkness, crying out at him in a horrible
discordant barrage. The creature came running swiftly, and the
alien's mind caught the sharp whine of fear and hate emanating
from the thing. It stopped before him, baring its fangs and snarling.
The alien lashed his foot out savagely; it crunched into flesh and
bone, and the creature lay flopping helplessly, spurting dark wet
stuff, its cry cut off in mid-yelp. The alien stepped onto the porch as
the door opened suddenly, framing a tall, thin man-thing in a box of
yellow light. "Brownie?" he called. "Come here, Brownie! What's the
matter—" His words trailed off when he saw the alien. "Who are
you?"
"A traveller," said the alien, his voice grating harshly in the darkness.
"I need lodging and food—"
The farmer's eyes narrowed suspiciously as he peered from the
doorway. "Come closer, let me get a look at you," he said.
The alien stepped closer, concentrating all his psi-faculties on the
farmer's mind, blurring his perception of the minute imperfections of
his disguise. It required all his power; he had none left to probe the
farmer's mind, and he waited, trembling. That could come later.
The farmer blinked, and nodded, finally. "All right," he said. "We've
got some food on the stove. Come on in."
II
III
Paul Faircloth finished reading the teletape briefing just as the little
jet plane slipped down toward the hangar slot in South Chicago. He
slapped the spools into the erasure can and flipped the control
switch to activate the distortion field inside the can. He stretched his
legs, then, wondering vaguely whether he was going to come out of
this whole mess alive.
Jean's parting hug was still warm in his memory, and he
remembered the worry in her big grey eyes as she had kissed him
and said, "Be careful, darling. I wish I could go, too. I couldn't bear
to have anything happen—" It was the first time she had ever
actually spoken that word to him, and he was glad she had. Almost
defiantly glad. She had said it aloud, and she had said so much,
much more without words. Only vague shadows in Faircloth's
untrained mind, but he knew the meaning of those shadows.
A man was waiting down below on the platform for him. The hangar
vault was dark and deserted. He took the agent's card and scanned
it briefly. "Marino? I'm Paul Faircloth. Better give me a late briefing."
Marino nodded. He was small and wiry, with catlike movements and
exceedingly bright eyes under his jet black eyebrows. "We'd be wise
to get on over while we talk," he said.
Faircloth nodded and stepped into the little tube-car that was waiting
at the end of the platform. It was a tight fit for two men, and Paul
ducked by reflex as it gave a lurch and dipped down the chute into a
narrow tunnel, hanging free and speeding ahead on its electronic
guide beam. "Is the Condor Building where he was spotted?"
Marino nodded. "In Center City, Chicago. First thirty-six floors are
commercial, and the twenty above are residential. He's pinned pretty
definitely on the forty-second, in a large residential suite. No idea
why he chose it or how long he's been there—" He turned apologetic
eyes to Faircloth. "I'm Psi-High—I guess you know. We've got him
located and triangulated, and we can keep him pretty well pinned if
he doesn't try to give us a shower. We're pretty sure he knows we're
there."
"Shower?"
Marino nodded, grimly tapping his forehead. "A barrage, the works.
This Alien's got a powerful psi. And I mean powerful. He gave it to
one of our Psi-High men yesterday. It was savage. Nearly ripped him
apart."
Faircloth shivered. "But you can keep track of him."
"Yes." Marino lit a cigarette with nervous fingers. "Roberts put Psi-
Highs out to spot him, but he doesn't want any Psi-Highs in on the
kill." His voice was flat with disappointment. "Political pressure, I
guess. People couldn't bear to give a Psi-High credit for anything—"
He glanced at Faircloth and reddened. "Sorry. No offense. It just
slipped out." He bit his lip. "Anyway, that's what you're here for. Half
a dozen other psi-negatives will help you. I hope God'll be helping
you too."
Faircloth grinned tightly. "Got you nervous?"
"It's got me plenty nervous."
Faircloth nodded again, rubbing a hand across his eyes. "All right. I
want your best men, every one of them, to go in with me. I don't
care whether they're Psi-High or not. Neither does Roberts; he's with
you folks all the way. But we've got to get this creature and get him
cold. He's slick. Is the building sewed up?"
"Tight as a vacutainer."
"Good. Keep it under cover, and try to keep the Psi-Highs from
broadcasting any more than necessary."
Marino gave him a queer look. "They'll do their best, of course."
"Right." Faircloth ran a hand through his brown hair and loosened
his tie a trifle. "As soon as the building is cleared from rush hour, I
want the power shut off all over the building. Elevators, lights,
everything. We'll be on the 41st floor, and a squad will be on the
43rd. We'll close in together."
Marino shook his head. "I hope it works. They had him just as tight
in Des Moines last week, and he slid right through." The man's eyes
were worried. "We just don't know what we're fighting. That's the
whole trouble. Even the Psi-Highs are up a tree."
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
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