Cocoa For Mac



Cocoa is a powerful collection of object-oriented tools and libraries that makes developing applications a much faster process. Mastery of Cocoa is absolutely essential for anyone doing serious development work for the Macintosh. 'Mac OS X and Cocoa are going to revolutionize the world of software development in the coming years. While Carbon is the means by which most Mac developers will get their apps up to speed for Mac OS X, Apple recommends Cocoa for developers with new ideas who are creating applications for the future. Cocoa Application Layer. The Cocoa application layer is primarily responsible for the appearance of apps and their responsiveness to user actions. In addition, many of the features that define the OS X user experience—such as Notification Center, full-screen mode, and Auto Save—are implemented by the Cocoa layer. Cocoa is a development API native to the Mac OS X operating system. Cocoa Touch is the closely-related analogous platform for the iOS. It is written in Objective-C, and acts as a sort of 'top layer' to each operating system.

Home > Store

Share|
Cocoa

Register your product to gain access to bonus material or receive a coupon.

  • By Aaron Hillegass
  • Published May 5, 2008 by Addison-Wesley Professional.

Book

  • Sorry, this book is no longer in print.

Description

  • Copyright 2008
  • Edition: 3rd
  • Book
  • ISBN-10: 0-321-50361-9
  • ISBN-13: 978-0-321-50361-9

The best-selling introduction to Cocoa, once again updated to cover the latest Mac programming technologies, and still enthusiastically recommended by experienced Mac OS X developers.

“Aaron’s book is the gold standard for Mac OS X programming books—beautifully written, and thoughtfully sculpted. The best book on Leopard development.”

—Scott Stevenson, www.theocacao.com

“This is the first book I’d recommend for anyone wanting to learn Cocoa from scratch. Aaron’s one of the few (perhaps only) full-time professional Cocoa instructors, and his teaching experience shows in the book.”

—Tim Burks, software developer and creator of the Nu programming language, www.programming.nu

“If you’re a UNIX or Windows developer who picked up a Mac OS X machine recently in hopes of developing new apps or porting your apps to Mac users, this book should be strongly considered as one of your essential reference and training tomes.”

—Kevin H. Spencer, Apple Certified Technical Coordinator

If you’re developing applications for Mac OS X, Cocoa® Programming for Mac® OS X, Third Edition, is the book you’ve been waiting to get your hands on. If you’re new to the Mac environment, it’s probably the book you’ve been told to read first. Covering the bulk of what you need to know to develop full-featured applications for OS X, written in an engaging tutorial style, and thoroughly class-tested to assure clarity and accuracy, it is an invaluable resource for any Mac programmer.

Specifically, Aaron Hillegass introduces the three most commonly used Mac developer tools: Xcode, Interface Builder, and Instruments. He also covers the Objective-C language and the major design patterns of Cocoa. Aaron illustrates his explanations with exemplary code, written in the idioms of the Cocoa community, to show you how Mac programs should be written. After reading this book, you will know enough to understand and utilize Apple’s online documentation for your own unique needs. And you will know enough to write your own stylish code.

Updated for Mac OS X 10.4 and 10.5, this revised edition includes coverage of Xcode 3, Objective-C 2, Core Data, the garbage collector, and CoreAnimation.

Extras

Related Articles

Author's Site

Please visit the author's website at www.bignerdranch.com.

Sample Content

Online Sample Chapter

Sample Pages

Table of Contents

Preface xvii

Acknowledgments xix

Chapter 1: Cocoa: What Is It? 1

A Little History 1

Tools 3

Language 4

Objects, Classes, Methods, and Messages 4

Frameworks 6

How to Read This Book 6

Typographical Conventions 7

Common Mistakes 7

How to Learn 8

Chapter 2: Let’s Get Started 9

In Xcode 9

In Interface Builder 13

Back in Xcode 23

Documentation 29

What Have You Done? 30

Chapter 3: Objective-C 33

Creating and Using Instances 33

Using Existing Classes 35

Creating Your Own Classes 46

The Debugger 58

What Have You Done? 62

For the More Curious: How Does Messaging Work? 62

Stellar for mac. For more than a decade, Jeffrey L. He now brings his knowledge and skillset to PCMag as Senior Analyst.When he isn't staring at a monitor (or two) and churning out Web hosting, music, utilities, and video game copy, Jeffrey mentors, practices Jeet Kune Do, blogs, podcasts, and speaks at the occasional con. Wilson has penned gadget- and video game-related nerd-copy for a variety of publications, including 1UP, 2D-X, The Cask, Laptop, LifeStyler, Parenting, Sync, Wise Bread, and WWE.

Challenge 64

Chapter 4: Memory Management 65

Turning the Garbage Collector On and Off 66

Living with the Garbage Collector 68

Living with Retain Counts 68

What Have You Done? 77

Chapter 5: Target/Action 79

Some Commonly Used Subclasses of NSControl 81

Start the SpeakLine Example 85

Lay Out the Nib File 86

Implementing the AppController Class 88

For the More Curious: Setting the Target Programmatically 90

Challenge 90

Debugging Hints 92

Chapter 6: Helper Objects 95

Delegates 96

The NSTableView and Its dataSource 99

Lay Out the User Interface 102

Make Connections 103

Edit AppController.m 105

For the More Curious: How Delegates Work 108

Challenge: Make a Delegate 109

Challenge: Make a Data Source 110

Chapter 7: Key-Value Coding; Key-Value Observing 111

Key-Value Coding 111

Bindings 113

Key-Value Observing 115

Making Keys Observable 116

Properties and Their Attributes 118

For the More Curious: Key Paths 120

For the More Curious: Key-Value Observing 121

Chapter 8: NSArrayController 123

Starting the RaiseMan Application 124

Key-Value Coding and nil 132

Add Sorting 133

For the More Curious: Sorting without NSArrayController 134

Challenge 1 135

Challenge 2 135

Chapter 9: NSUndoManager 139

NSInvocation 139

Cocoa For A Cough

How the NSUndoManager Works 140

Adding Undo to RaiseMan 142

Key-Value Observing 145

Undo for Edits 146

Begin Editing on Insert 149

For the More Curious: Windows and the Undo Manager 151

Chapter 10: Archiving 153

NSCoder and NSCoding 154

The Document Architecture 157

Saving and NSKeyedArchiver 161

Loading and NSKeyedUnarchiver 162

Setting the Extension and Icon for the File Type 163

For the More Curious: Preventing Infinite Loops 166

For the More Curious: Creating a Protocol 167

For the More Curious: Document-Based Applications without Undo 167

Universal Type Identifiers 168

Chapter 11: Basic Core Data 171

NSManagedObjectModel 171

Interface 173

How Core Data Works 180

Chapter 12: Nib Files and NSWindowController 183

NSPanel 183

Adding a Panel to the Application 184

For the More Curious: NSBundle 194

Challenge 195

Chapter 13: User Defaults 197

NSDictionary and NSMutableDictionary 198

NSUserDefaults 200

Setting the Identifier for the Application 202

Creating Keys for the Names of the Defaults 202

Registering Defaults 203

Letting the User Edit the Defaults 203

Using the Defaults 205

For the More Curious: NSUserDefaultsController 207

For the More Curious: Reading and Writing Defaults from the Command Line 207

Challenge 208

Chapter 14: Using Notifications 209

What Notifications Are 209

What Notifications Are Not 210

NSNotification and NSNotificationCenter 210

Posting a Notification 212

Registering as an Observer 213

Handling the Notification When It Arrives 214

The userInfo Dictionary 214

For the More Curious: Delegates and Notifications 215

Challenge 216

Chapter 15: Using Alert Panels 217

Make the User Confirm the Deletion 218

Challenge 221

Chapter 16: Localization 223

Localizing a Nib File 224

Cocoa For Mac

String Tables 226

DownThemAll!, Neat Download Manager for Mac, and Folx are probably your best bets out of the 9 options considered. 'Increase download speeds' is the primary reason people pick DownThemAll! Over the competition. This page is powered by a knowledgeable community that. Download manager for mac. Folx PRO is a download manager for Mac OS X that is the closest alternative to Internet Download Manager (IDM) on Windows. Folx can integrate with popular browsers such as Safari, Firefox, Opera and Chrome and fetches downloads. Folx is a 2-in-1 internet download manager - common downloader and torrent downloader. It includes tons of torrent trackers' URLs so you can download videos and music for totally free. Download IDM for Mac alternative now. (YouTube downloading is NOT supported by Folx. To download YouTube video, Get Eltima Airy for Mac).

For the More Curious: ibtool 230

For the More Curious: Explicit Ordering of Tokens in Format Strings 231

Chapter 17: Custom Views 233

The View Hierarchy 233

Getting a View to Draw Itself 235

Drawing with NSBezierPath 240

NSScrollView 242

Creating Views Programmatically 245

For the More Curious: Cells 245

For the More Curious: isFlipped 247

Challenge 248

Chapter 18: Images and Mouse Events 249

NSResponder 249

NSEvent 249

Getting Mouse Events 251

Using NSOpenPanel 251

Composite an Image onto Your View 256

The View’s Coordinate System 258

Autoscrolling 261

For the More Curious: NSImage 261

Challenge 262

Chapter 19: Keyboard Events 263

NSResponder 265

NSEvent 265

Create a New Project with a Custom View 266

For the More Curious: Rollovers 274

The Fuzzy Blue Box 275

Chapter 20: Drawing Text with Attributes 277

NSFont 277

NSAttributedString 278

Drawing Strings and Attributed Strings 280

Making Letters Appear 281

Getting Your View to Generate PDF Data 283

For the More Curious: NSFontManager 286

Challenge 1 286

Mac Sweet As Cocoa

Challenge 2 286

Chapter 21: Pasteboards and Nil-Targeted Actions 287

NSPasteboard 288

Add Cut, Copy, and Paste to BigLetterView 289

Nil-Targeted Actions 290

For the More Curious: Which Object Sends the Action Message? 293

For the More Curious: Lazy Copying 293

Challenge 1 294

Challenge 2 294

Chapter 22: Categories 295

Add a Method to NSString 295

For the More Curious: Declaring Private Methods 297

For the More Curious: Declaring Informal Protocols 297

Chapter 23: Drag-and-Drop 299

Make BigLetterView a Drag Source 300

Make BigLetterView a Drag Destination 303

For the More Curious: Operation Mask 307

Chapter 24: NSTimer 309

Lay Out the Interface 311

Make Connections 312

Adding Code to AppController 314

For the More Curious: NSRunLoop 316

Hosts for mac os x. Challenge 316

Chapter 25: Sheets 317

Adding a Sheet 318

For the More Curious: contextInfo 324

Cocoa Framework

For the More Curious: Modal Windows 325

Chapter 26: Creating NSFormatters 327

A Basic Formatter 328

The delegate of the NSControl 334

Checking Partial Strings 335

Formatters That Return Attributed Strings 337

Chapter 27: Printing 339

Dealing with Pagination 339

For the More Curious: Am I Drawing to the Screen? 344

Challenge 344

Chapter 28: Web Service 345

AmaZone 346

Lay Out the Interface 347

Write Code 349

Challenge: Add a WebView 353

Chapter 29: View Swapping 355

Design 356

Resizing the Window 362

Chapter 30: Core Data Relationships 365

Edit the Model 365

Create Custom NSManagedObject Classes 366

Lay Out the Interface 369

Events and nextResponder 372

Chapter 31: Garbage Collection 375

Non-object Data Types 376

Polynomials Example 377

Instruments 383

For the More Curious: Weak References 385

Challenge: Do Bad Things 385

Chapter 32: Core Animation 387

Creating CALayer 388

Using CALayer and CAAnimation 390

Chapter 33: A Simple Cocoa/OpenGL Application 397

Using NSOpenGLView 397

Writing the Application 398

Chapter 34: NSTask 405

Multithreading versus Multiprocessing 405

ZIPspector 406

Asynchronous Reads 410

iPing 411

Challenge: .tar and .tgz files 415

Chapter 35: The End 417

Challenge 418

Index 419

More Information

Other Things You Might Like

  • eBook (Watermarked) $28.79
  • Book $35.99
  • Book $39.99

This directory contains binaries for a base distribution and packages to run on Mac OS X (release 10.6 and above). Mac OS 8.6 to 9.2 (and Mac OS X 10.1) are no longer supported but you can find the last supported release of R for these systems (which is R 1.7.1) here. Releases for old Mac OS X systems (through Mac OS X 10.5) and PowerPC Macs can be found in the old directory.

Note: CRAN does not have Mac OS X systems and cannot check these binaries for viruses.Although we take precautions when assembling binaries, please use the normal precautions with downloaded executables.

Package binaries for R versions older than 3.2.0 are only available from the CRAN archive so users of such versions should adjust the CRAN mirror setting (https://cran-archive.r-project.org) accordingly.

R 4.0.3 'Bunny-Wunnies Freak Out' released on 2020/10/10

Please check the MD5 checksum of the downloaded image to ensure that it has not been tampered with or corrupted during the mirroring process. For example type
openssl sha1 R-4.0.3.pkg
in the Terminal application to print the SHA1 checksum for the R-4.0.3.pkg image. On Mac OS X 10.7 and later you can also validate the signature using
pkgutil --check-signature R-4.0.3.pkg

Latest release:

R-4.0.3.pkg (notarized and signed)
SHA1-hash: 8402f586aef1fdb12c6e34c73b286f87318fb1be
(ca. 85MB)
R 4.0.3 binary for macOS 10.13 (High Sierra) and higher, signed and notarized package. Contains R 4.0.3 framework, R.app GUI 1.73 in 64-bit for Intel Macs, Tcl/Tk 8.6.6 X11 libraries and Texinfo 6.7. The latter two components are optional and can be ommitted when choosing 'custom install', they are only needed if you want to use the tcltk R package or build package documentation from sources.

Note: the use of X11 (including tcltk) requires XQuartz to be installed since it is no longer part of OS X. Always re-install XQuartz when upgrading your macOS to a new major version.

Important: this release uses Xcode 10.1 and GNU Fortran 8.2. If you wish to compile R packages from sources, you will need to download and GNU Fortran 8.2 - see the tools directory.

NEWS (for Mac GUI)News features and changes in the R.app Mac GUI
Mac-GUI-1.73.tar.gz
SHA1-hash: 7f4b1d050757ce78545bdeb9d178a69d13046aa1
Sources for the R.app GUI 1.73 for Mac OS X. This file is only needed if you want to join the development of the GUI, it is not intended for regular users. Read the INSTALL file for further instructions.
Note: Previous R versions for El Capitan can be found in the el-capitan/base directory.

Binaries for legacy OS X systems:

R-3.6.3.nn.pkg (signed)
SHA1-hash: c462c9b1f9b45d778f05b8d9aa25a9123b3557c4
(ca. 77MB)
R 3.6.3 binary for OS X 10.11 (El Capitan) and higher, signed package. Contains R 3.6.3 framework, R.app GUI 1.70 in 64-bit for Intel Macs, Tcl/Tk 8.6.6 X11 libraries and Texinfo 5.2. The latter two components are optional and can be ommitted when choosing 'custom install', they are only needed if you want to use the tcltk R package or build package documentation from sources.
R-3.3.3.pkg
MD5-hash: 893ba010f303e666e19f86e4800f1fbf
SHA1-hash: 5ae71b000b15805f95f38c08c45972d51ce3d027

(ca. 71MB)
R 3.3.3 binary for Mac OS X 10.9 (Mavericks) and higher, signed package. Contains R 3.3.3 framework, R.app GUI 1.69 in 64-bit for Intel Macs, Tcl/Tk 8.6.0 X11 libraries and Texinfo 5.2. The latter two components are optional and can be ommitted when choosing 'custom install', it is only needed if you want to use the tcltk R package or build package documentation from sources.

Note: the use of X11 (including tcltk) requires XQuartz to be installed since it is no longer part of OS X. Always re-install XQuartz when upgrading your OS X to a new major version.

R-3.2.1-snowleopard.pkg
MD5-hash: 58fe9d01314d9cb75ff80ccfb914fd65
SHA1-hash: be6e91db12bac22a324f0cb51c7efa9063ece0d0

(ca. 68MB)
R 3.2.1 legacy binary for Mac OS X 10.6 (Snow Leopard) - 10.8 (Mountain Lion), signed package. Contains R 3.2.1 framework, R.app GUI 1.66 in 64-bit for Intel Macs.
This package contains the R framework, 64-bit GUI (R.app), Tcl/Tk 8.6.0 X11 libraries and Texinfop 5.2. GNU Fortran is NOT included (needed if you want to compile packages from sources that contain FORTRAN code) please see the tools directory.
NOTE: the binary support for OS X before Mavericks is being phased out, we do not expect further releases!
The new R.app Cocoa GUI has been written by Simon Urbanek and Stefano Iacus with contributions from many developers and translators world-wide, see 'About R' in the GUI.

Subdirectories:

toolsAdditional tools necessary for building R for Mac OS X:
Universal GNU Fortran compiler for Mac OS X (see R for Mac tools page for details).
baseBinaries of R builds for macOS 10.13 or higher (High Sierra)
contribBinaries of package builds for macOS 10.13 or higher (High Sierra)
el-capitanBinaries of package builds for OS X 10.11 or higher (El Capitan build)
mavericksBinaries of package builds for Mac OS X 10.9 or higher (Mavericks build)
oldPreviously released R versions for Mac OS X

You may also want to read the R FAQ and R for Mac OS X FAQ. For discussion of Mac-related topics and reporting Mac-specific bugs, please use the R-SIG-Mac mailing list.

Information, tools and most recent daily builds of the R GUI, R-patched and R-devel can be found at http://mac.R-project.org/. Please visit that page especially during beta stages to help us test the Mac OS X binaries before final release!

Package maintainers should visit CRAN check summary page to see whether their package is compatible with the current build of R for Mac OS X.

Binary libraries for dependencies not present here are available from http://mac.R-project.org/libs and corresponding sources at http://mac.R-project.org/src.

Last modified: 2020/10/10, by Simon Urbanek