[APPLE] Object-Oriented Programming and the Objective-C Language (2000).pdf
(
1561 KB
)
Pobierz
INSIDE COCOA
Object-Oriented Programming and
the Objective-C Language
December 2000
Apple
Computer, Inc.
© 1993-1995, 2000 Apple Computer,
Inc.
All rights reserved.
No part of this publication may be re-
produced, stored in a retrieval sys-
tem, or transmitted, in any form or by
any means, mechanical, electronic,
photocopying, recording, or other-
wise, without prior written permis-
sion of Apple Computer, Inc., with
the following exceptions: Any person
is hereby authorized to store docu-
mentation on a single computer for
personal use only and to print copies
of documentation for personal use
provided that the documentation
contains Apple’s copyright notice.
The Apple logo is a trademark of Ap-
ple Computer, Inc.
Use of the “keyboard” Apple logo
(Option-Shift-K) for commercial pur-
poses without the prior written con-
sent of Apple may constitute
trademark infringement and unfair
competition in violation of federal
and state laws.
No licenses, express or implied, are
granted with respect to any of the
technology described in this book.
Apple retains all intellectual property
rights associated with the technology
described in this book. This book is
intended to assist application devel-
opers to develop applications only for
Apple-labeled or Apple-licensed
computers
Every effort has been made to ensure
that the information in this document
is accurate. Apple is not responsible
for typographical errors.
Apple Computer, Inc.
1 Infinite Loop
Cupertino, CA 95014
408-996-1010
Apple, the Apple logo, and Macin-
tosh are trademarks of Apple Com-
puter, Inc., registered in the United
States and other countries.
Simultaneously published in the
United States and Canada
Even though Apple has reviewed this
manual, APPLE MAKES NO WARRAN-
TY OR REPRESENTATION, EITHER EX-
PRESS OR IMPLIED, WITH RESPECT
TO THIS MANUAL, ITS QUALITY, AC-
CURACY, MERCHANTABILITY, OR
FITNESS FOR A PARTICULAR PUR-
POSE. AS A RESULT, THIS MANUAL IS
SOLD “AS IS,” AND YOU, THE PUR-
CHASER, ARE ASSUMING THE EN-
TIRE RISK AS TO ITS QUALITY AND
ACCURACY.
IN NO EVENT WILL APPLE BE LIABLE
FOR DIRECT, INDIRECT, SPECIAL, IN-
CIDENTAL, OR CONSEQUENTIAL
DAMAGES RESULTING FROM ANY
DEFECT OR INACCURACY IN THIS
MANUAL, even if advised of the possi-
bility of such damages.
THE WARRANTY AND REMEDIES SET
FORTH ABOVE ARE EXCLUSIVE AND
IN LIEU OF ALL OTHERS, ORAL OR
WRITTEN, EXPRESS OR IMPLIED. No
Apple dealer, agent, or employee is au-
thorized to make any modification, exten-
sion, or addition to this warranty.
Some states do not allow the exclusion or
limitation of implied warranties or liabil-
ity for incidental or consequential damag-
es, so the above limitation or exclusion
may not apply to you. This warranty gives
you specific legal rights, and you may
also have other rights which vary from
state to state.
Contents
Chapter 1
Introduction
9
The Development Environment
10
Why Objective-C
11
How the Book Is Organized
12
Conventions
13
Chapter 2
Object-Oriented Programming
15
Interface and Implementation
16
The Object Model
20
The Messaging Metaphor
22
Classes
24
Modularity
25
Reusability
26
Mechanisms Of Abstraction
28
Encapsulation
28
Polymorphism
29
Inheritance
31
Class Hierarchies
32
Subclass Definitions
33
Uses of Inheritance
33
Dynamism
35
Dynamic Typing
36
Dynamic Binding
37
Dynamic Loading
39
Structuring Programs
40
Outlet Connections
41
Extrinsic and Intrinsic Connections
42
Activating the Object Network
43
Aggregation and Decomposition
44
Models and Frameworks
45
Structuring the Programming Task
46
3
C O N T E N T S
Collaboration
47
Organizing Object-Oriented Projects
47
Designing on a Large Scale
48
Separating the Interface from the Implementation
Modularizing the Work
48
Keeping the Interface Simple
49
Making Decisions Dynamically
49
Inheriting Generic Code
49
Reusing Tested Code
49
48
Chapter 3
The Objective-C Language
51
Objects
51
id
52
Dynamic Typing
53
Messages
54
The Receiver’s Instance Variables
55
Polymorphism
56
Dynamic Binding
56
Classes
58
Inheritance
58
The NSObject Class
60
Inheriting Instance Variables
60
Inheriting Methods
61
Overriding One Method With Another
Abstract Classes
62
Class Types
63
Static Typing
63
Type Introspection
64
Class Objects
65
Creating Instances
66
Customization With Class Objects
67
Variables and Class Objects
68
Initializing a Class Object
69
Methods of the Root Class
70
Class Names in Source Code
70
Defining a Class
71
62
4
C O N T E N T S
The Interface
72
Importing the Interface
74
Referring to Other Classes
75
The Role of the Interface
76
The Implementation
76
Referring to Instance Variables
78
The Scope of Instance Variables
79
How Messaging Works
83
Selectors
86
Methods and Selectors
87
Method Return and Argument Types
87
Varying the Message at Run Time
88
The Target-Action Paradigm
88
Avoiding Messaging Errors
90
Hidden Arguments
91
Messages to self and super
91
An Example
93
Using super
95
Redefining self
96
Chapter 4
Objective-C Extensions
99
Categories
99
Adding to a Class
100
How Categories Are Used
101
Categories of the Root Class
102
Protocols
103
How Protocols Are Used
104
Methods for Others to Implement
104
Anonymous Objects
105
Non-Hierarchical Similarities
107
Informal Protocols
108
Formal Protocols
108
Protocol Objects
110
Conforming to a Protocol
111
Type Checking
111
5
Plik z chomika:
Ryjufka
Inne pliki z tego folderu:
[SAMS] Cocoa Programming (Scott Anguish) (2002).pdf
(9155 KB)
Advanced Graphics Programming Using OpenGL (Tom McReynolds, David Blythe).pdf
(13052 KB)
Absolute FreeBSD (Michael W. Lucas).pdf
(7836 KB)
Beginning iOS Game Development (Patrick Alessi).pdf
(20539 KB)
Begining iPad Development for iPhone Developers (Jack Nutting).pdf
(6606 KB)
Inne foldery tego chomika:
[Eng] Android books
BPM Business Process Modeling
IT Ebooks Mega Pack
IT Ebooks Programming
IT epub
Zgłoś jeśli
naruszono regulamin