Table of Contents

foreword xiii
preface xv
acknowledgments xviii
about this book xix
about the author xxiii
about the cover illustration xxiv


Part 1  Overview   1


1  Welcome to Mac OS X   3
1.1 Introduction 4
Origins of Mac OS X 5
1.2 The Macintosh user interface 6
1.3 The Mac OS X user interface 8
The desktop 8 n Menus 8
The Dock 10
Window layering 11
Dialog boxes 11
Drawers 12
Keyboard navigation 12
Other interface features 13
1.4 The Mac OS X architecture 13
Architecture layers 15
The kernel environment 16
Core Services layer 20
Application Services layer 21
Application Environment layer 22
Aqua 26
1.5 Summary 26
2  Navigating and using Mac OS X   27
2.1 Introduction 28
2.2 Shells 29
Terminal features 31
2.3 Help system 32
Help Viewer 33
2.4 User accounts and privileges 33
Creating user accounts 34
2.5 Booting and default services 36
2.6 Programs and Mac OS X bundles 37
2.7 Security issues 39
2.8 File system 39
Finder 41
Case sensitivity and pathname delimiters 43
2.9 Single-user mode 44
2.10 System log files 45
2.11 Processes management 45
2.12 Common commands and tools 46
2.13 Scripting languages 48
AppleScript 48
2.14 Development tools 50
2.15 X Window under Mac OS X 51
Installing the X server 52
2.16 UNIX to Mac OS X software projects 53
2.17 Summary 54

Part 2  Tools   55


3  Project Builder and Interface Builder   57
3.1 Introduction 58
Macintosh Programmer?s Workbench 59
THINK Pascal and THINK C 59
CodeWarrior 60
Project Builder and Interface Builder 60
3.2 Creating an application with Project Builder 62
3.3 Project Builder in depth 67
Targets and build styles 67
Project Builder?s UNIX tools 68
Project Builder?s interface 69
Project Builder scenarios 78
3.4 Creating an application with Interface Builder 100
Interface Builder scenarios 101
3.5 Summary 108
4  Development tools   109
4.1 Introduction 110
4.2 UNIX development tools under Mac OS X 112
Editors 112
Mac OS X editing tools 113
Version control 117
Static code analysis tools 121
4.3 Compilers and build tools 122
4.4 Mac OS X Aqua-based development tools 122
UNIX-based editors 122
Mac OS X-based editors 127
4.5 Apple?s GUI-based development tools 127
Apple Help Indexing Tool 128
AppleScript Studio 128
FileMerge 129
Icon Composer 132
Interface Builder 132
JavaBrowser 133
MRJAppBuilder 134
MallocDebug 135
ObjectAlloc 143
PEF Viewer 143
PackageMaker 144
Pixie 144
Project Builder 144
PropertyListEditor 144
Quartz Debug 146
Sampler 147
Thread Viewer 150
icns Browser 155
4.6 Apple?s command-line development tools 156
ps (process status) and top (system usage statistics) 156
sc_usage: showing system call usage statistics 158
fs_usage: reporting system calls and page faults related to the filesystem in real-time 160
gprof: displaying execution profile data 161
leaks: searching a process?s memory for unreferenced malloc buffers 163
heap: listing all the malloc-allocated buffers in the process?s heap 165
malloc_history: showing malloc allocations that a process has performed 165
sample: profiling a process during a time interval 166
4.7 Summary 167

Part 3  Programming   169


5  Objective-C and the Cocoa development frameworks   171
5.1 Introduction 172
5.2 Introduction to Objective-C 173
Object-oriented terminology 174
Classes 175
Messages 177
Categories 178
Protocols 180
Other features 180
Why learn Objective-C? 181
5.3 Cocoa software infrastructure 182
Foundation 182
Application Kit 187
Memory management 188
Design patterns 193
Cocoa event handling 197
5.4 Other Cocoa development languages 200
C++ 201
Perl 201
Ruby 202
5.5 Summary 202
6  Cocoa programming   203
6.1 Introduction 204
6.2 The CocoaWGet example program 205
6.3 Program requirements 207
6.4 Program design 208
6.5 Building the interface 209
Opening the project 209
The interface components 210
Control alignment and spacing 212
Forms 215
Classes and instances 215
6.6 CocoaWGet: implementing code with Project Builder 220
The model 221
The view 224
The controller 224
6.7 Program extensions 233
Letting the user cancel downloads 234
The application icon 239
The help file 241
6.8 Summary 243
7  AppleScript programming   245
7.1 Introduction 246
7.2 Scripting languages 247
7.3 AppleScript 248
Creating and running a script 250
Types of AppleScripts 251
AppleScript extensions 252
The AppleScript language 254
Choosing a scripting language 264
7.4 Example applications of AppleScript 264
iTunes and AppleScript 264
AppleScript Studio 269
7.5 Summary 278
8  Mac OS X and beyond   279
8.1 Introduction 280
8.2 Development tools 281
Compilers 281
Project Builder 283
Changing compilers 283
Inline scripting 283
New target editor 286
Searching documentation 287
8.3 Terminal application 289
Setting Terminal preferences 289
Splitting the Terminal window 292
Other Terminal additions 293
8.4 The PerlObjCBridge 293
PerlObjCBridge example 295
8.5 Summary 300

A  Getting and installing development tools   301

B  UNIX and Mac OS X command mappings   303
B.1 Common Mac OS X operations 304
B.2 UNIX file/directory commands mapped to Mac OS X commands 304
List directory contents: ls 304
Copy/move files or folders: cp, mv 305
Remove files or folders: rm 305
Change directory: cd 305
Create a new directory: mkdir 305
Change file permission and group: chmod, chgrp 306
Compare files: diff 306
Get the word, line, or byte count: wc 306
Compress and decompress data: compress, uncompress, tar, gzip, gnuzip, unzip, zcat 306
Edit text files: emacs, vi 306
View files: head, tail 306
Find files: find 307
B.3 UNIX communication commands mapped to Mac OS X commands 307
OpenSSH: ssh, scp 307
Talk to another user: talk, ytalk 307
B.4 UNIX process management commands mapped to Mac OS X commands 307
Show system and process usage statistics: top, ps 307
Terminate a process: kill 307

C  The precursor of Mac OS X: Mac OS   309
C.1 A tour of the Mac OS interface 310
C.2 Interacting with the system 312
C.3 Mac OS system components 313
System file and Finder 314
Process scheduling 314
Memory management 315
Extending the system through system extensions 317
Interapplication communication (IAC) 318
File system 319
Macintosh files 319
Graphics 320
Networking 321

D  A brief history of UNIX   323
D.1 The origin of UNIX 324
High-level languages and punch cards 324
Batch processing 325
Time-sharing 326
D.2 The birth and development of UNIX 328
D.3 GNU, Free Software Foundation, and open source 333
D.4 UNIX software development philosophy 335

resources 337

index 345