Discovering Openstep: a Developer Tutorial

Discovering Openstep: a Developer Tutorial

DISCOVERING OPENSTEP: A DEVELOPER TUTORIAL Object-Oriented Software DISCOVERING OPENSTEP: A Developer Tutorial Release 4.0 for Mach f· NeXT Software, Inc. 900 Chesapeake Drive Redwood City, CA 94063 U.S.A. We at NeXT have tried to make the information contained in this publication as accurate and reliable as possible. Nevertheless, NeXT disclaims any warranty of any kind, whether express or implied, as to any matter whatsoever relating to this publication, including without limitation the merchantability or fitness for any particular purpose. NeXT will from time to time revise the software described in this publication and reserves the right to make such changes without the obligation to notify the purchaser. In no event shall NeXT be liable for any indirect, special, incidental, or consequential damages arising out of purchase or use of this publication or the information contained herein. Restricted Rights Legend: Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1 )(ij) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 (or, if applicable, similar clauses at FAR 52.227-19 or NASA FAR Supp. 52.227-86). Copyright 1993-1996 NeXT Software, Inc. All Rights Reserved. [6863.00] NeXT, the NeXT logo, NEXTSTEp, Netlnfo, and Objective-C are registered trademarks of NeXT Software, Inc. The NEXTSTEP logo, Application Kit, Enterprise Object, Enterprise Objects Framework, Interface Builder, OPENSTEp, the OPENSTEP logo, PDO, Portable Distributed Objects, WebObjects, and Workspace Manager are trademarks of NeXT Software, Inc. Use in commerce other than as "fair use" is prohibited by law except by express license from NeXT Software, Inc. PostScript is a registered trademark of Adobe Systems, Incorporated. Unix is a registered trademark of UNIX Systems Laboratories, Inc. All other trademarks mentioned belong to their respective owners. U.S. and foreign patents are pending on NeXT products. Netlnfo: U.S. Patent No. 5,410,691 NEXTSTEP: U.S. Patent Nos. 5,184,124; 5,355,483; 5,388,201; 5,423,039; 5,432,937. Cryptography: U.S. Patent Nos. 5,159,632; 5,271,061. Address inquiries concerning usage of NeXT trademarks, designs, or patents to General Counsel, NeXT Software, Inc., 900 Chesapeake Drive, Redwood City, CA 94063 USA.} Written by: Terry Donoghue Tutorial applications by: Terry Donoghue Art and Production management: Terri FitzMaurice Book design: Karin Stroud Publications management: Ron Hayden With help from: Trey Matteson, Ron Hayden, Jean Ostrem, Lynn Cox, Derek Clegg, and Kelly Toshach Cover design: CKS Partners, San Francisco, California Table of Contents 1 Introduction 111 To Do Tutorial 6 What is OPENSTEP? 117 The Design of To Do 8 Power Programming with OPEN STEP Developer 121 Setting up the To Do Project 10 The Advantage of Objects 122 Creating the Model Class (ToDoltem) 11 The Advantage of OPENSTEP 128 Subclass Example: Adding Data and Behavior (CalendarMatrix) Why NSMatrix? 128 13 Currency Converter Tutorial 139 The Basics of a Multi-Document Application 19 Creating the Currency Converter Project 150 Managing Documents Through Delegation 21 Creating the Currency Converter Interface 153 Managing the Data and Coordinating its Display 34 Designing the Currency Converter Application (ToDoDoc) 37 Defining the Classes of Currency Converter 160 Subclass Example: Overriding Behavior Connecting ConverterControlier to the Interface 42 (SelectionNotifMatrix) 46 Implementing the Classes of Currency Converter 164 Creating and Managing an Inspector (ToDolnspector) 51 Building the Currency Converter Project 181 Subclass Example: Overriding and Adding Behavior (ToDoCell) 56 Run Currency Converter 187 Setting Up Timers for Notification Messages 57 Travel Advisor Tutorial 190 Build, Run, and Extend the Application Optional Exercises 191 62 Creating the Travel Advisor Interface World Wide Web 197 73 The Design of Travel Advisor Model Objects 73 193 Where To Go From Here Controller 74 198 Programming Tools and Resources 76 Defining the Classes of Travel Advisor 201 Information 82 Implementing the Country Class 203 Professional Services 90 Implementing the TAController Class Data Mediation 92 205 Ordering NeXT Products and Services Getting the Table View to Work 95 Adding and Deleting Records 100 Field Formatting and Validation 102 Application Management 105 109 Building and Running Travel Advisor Table of Contents 209 Appendix A: Object-Oriented Programming 214 Objects Encapsulation 214 Messages 215 An Object-Oriented Program 216 Polymorphism and Dynamic Binding 217. 219 Classes Object Creation 219 Inheritance 220 Defining a Class 222 224 Categories and Protocols Concepts 13 Currency Converter Tutorial 88 Object Ownership, Retention, and Disposal 91 Turbo Coding With Project Builder 20 Project Indexing 94 Finding Information Within Your Project 22 A Window in OpenStep 97 Getting in on the Action: Delegation and Notification 28 Aligning on a Grid 101 Abstract Classes and Class Clusters 32 An OpenStep Application - What You Get "For Free" 103 Behind "Click Here": Controls, Cells, and Formatters 33 An OpenStep Application - The Possibilities 106 Flattening the Object Network: Coding and Archiving 34 Why an Object is Like a Jelly Donut 108 Using the Graphical Debugger 36 The Model-View-Controller Paradigm 109 lips for Eliminating Deallocation Bugs 37 Class Versus Object 40 Paths for Object Communication: Outlets, Targets, and Actions 111 To Do Tutorial 50 Objective-C Quick Reference 116 Starting Up - What Happens in NSApplicationMainO 52 What Happens When You Build an Application 118 Only When Needed: Dynamically Loading Resources and 54 Where To Go For Help Code 134 Dates and limes in OpenStep 57 Travel Advisor Tutorial 141 The Structure of Multi-Document Applications 143 Coordinate Systems in OpenStep 63 Varieties of Buttons 148 The Application Quartet: NSResponder, NSApplication, 64 More About Forms NSWindow, and NSView 66 More About Table Views 162 Events and the Event Cycle 74 The Collection Classes 178 A Short Guide to Drawing and Compositing 79 Checking Connections in Outline Mode 180 Making a Custom View 80 File's Owner 181 Why Chose NSButtonCell as Superclass? 81 Just Add a Smock: Compiled and Dynamic Palettes 189 lick Tock Brrrring: Run Loops and limer 82 NSString: A String for All Countries 84 The Foundation Framework: Capabilities, Concepts, and Paradigms iii Table of Contents iv tjciono Projects :b;1j Delete ry Jill ~24-Hour 05,.:,5.2,; ,~~tJ ~ Chapter 1 Introduction Sections What is OPENSTEP? Power Programming With OPENSTEP Developer The Advantage of Objects The Advantage of OPENSTEP 3 Introduction 4 When you begin any enterprise, you must find a starting point. You set out from that starting point and acquire a basic vocabulary, a notion of boundaries and techniques, a sense of how things fit together and what is possible. For those who want to learn how to create OPENSTEP applications, this book provides a starting point. With this book you become familiar with OPENSTEP application development not merely by reading but by doing. The book guides you through the creation of three applications of increasing complexity. Along the way it explains related concepts and issues. The techniques and concepts you learn in one tutorial lay the foundation for the more advanced techniques and concepts in the next tutorial. The final chapter of the book tells you where to go for further information and where and how to find things, such as tools and documentation. It also tells you how to get NeXT products and services. This book covers a lot of ground, although sometimes at only a summary level. Finishing this book makes you much better prepared to take on serious application development with OPENSTEP in general and the Enterprise Object Framework in particular. Although the aim is primarily to educate, this book is also intended-for those interested in programming-to be fun. Some of you might be new to OPENSTEP. To learn more about OPENSTEp, the standard on which it's based, and OPENSTEP Developer, turn the page. 5 Chapter 1 Introduction to OPENSTEP OPENSTEP is NeXT Software's graphical, object-oriented user OpenStep and development environment. It is based on the OpenStep standard and available on a variety of platforms. OPENSTEP is OpenStep is the software industry's first open standard for object­ earning a growing reputation in the corporate world as the oriented software development. It is an application programming premier environmentfor developing and deploying mission­ interface (API) based on the fundamental NEXTSTEP object layer: critical custom applications. the Application Kit, the Foundation Kit, and Display PostScript. The two core components ofthe product are OPENSTEP User and OPENSTEP Developer. Applications Application Kit OPENSTEP User is a user environment Display Foundation acclaimed for its intuitively navigable desktop Postscript Kit 0IifHSfBi and file manager. On it you can easily deploy your own OPENSTEP applications as well as those OpenStep supplied by NeXT and third-party vendors. Intelligent networking, particularly Netlnfo, makes it possible to install and upgrade OPENSTEP in a fraction of the time it takes other systems. The OpenStep object layer allows corporate customers to create, evolve OPENSTEP Developer, NeXT's software­ and deploy multi-tier; client/server business applications in a fraction of development environment, provides time it takes other methods. seamlessly integrated set of tools for building • Application

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    240 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us