DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

Tutorials 

Cocoa For Amateurs - Preamble

by Dr. John Timmer, Contributing Editor

Cocoa for Amateurs

OSXfaq is a site devoted to helping the more technically-minded users get the most out of OS-X. This usually means finding easier ways of accomplishing repetitive or difficult tasks, either through buried features of the OS or by using its extensive scripting abilities and Unix utilities. In the end, however, there are limits to what you can accomplish without making your own solution - in other words, writing your own program. If you've reached the point where you'd like to try, this series of tutorials may be for you.

Who is this for?
I say "may be for you", because it will be targeted at users who are the "amateurs" in the series title. I'll start by defining this audience by who it is not. Amateurs clearly rank below professionals, who have to need to know the OS and programming environment inside and out and will extensively plan their project's features and needs well in advance. Given their status, they also have both the time and resources to devote to achieving that level of competence, and the resources to spend money on their development tools. Amateurs rank a bit above novices, though, who have little programming experience and are likely to set limited goals for their projects; this crowd will probably be better served by environments such as AppleScript Studio and REALbasic.

Amateurs (such as myself) fall somewhere in between. We know how to program, but they either don't make a living out of it or balance time between multiple languages and environments. The simpler environments that appeal to beginners can frustrate an amateur by placing too many barriers between them and what the OS offers, while learning the OS'es full toolkit seems so overwhelming that we don't know where to start. Our projects may have a fairly advanced goal, but they get worked on in fits and starts as I find spare time, limiting the level of organization and planning. In addition, the money we can spend on development tools is pretty limited, so we tend to go with the freebies, like Project Builder.

How does this differ from other tutorials out there?
Targeting this audience will necessarily affect how these tutorials are put together. Most tutorials focus on how to perform a specific task, and present you with organized, flawless code for performing that task. These will be quite different. Since I will focus on the process of learning how do work with Cocoa as they go, I'm going to include details such as the Google searches that came up with instructions and sample code. Instead of laying things out in an organized fashion, I'll be adding features as the project matures, since that's mostly how projects done in spare time actually happen. I'll also point out the places where I did things wrong, and how I found and fixed those errors. In short, I'm going to try to provide a recipe for writing code and handling problems for projects unrelated to the ones I cover, so that these tutorials will help people work on their own. In addition, if I get useful reader feedback on these articles, I'll do my best to update them, so watch the table of contents for notes on modifications of older tutorials.

What should you know?
To make sense out of these, you should know how to program (pretty much any language will do - it's the thought process that counts), and you should have a basic understanding of object-oriented programming. That's about it - most of the other concepts will be introduced and explained as we go along. That said, these two things are asking quite a lot. Knowing how to program implies that you can take a given task and break it down to individual steps that can be accomplished with a given programming language.

Understanding Object Oriented Programming is even harder for most people to come to grips with - there are several significant differences between typical procedural programming and creating working with objects. Although using Apple's development tools and Cocoa classes compels one to work in an object-oriented manner, it's easiest to follow what's going on in example code if you already have some grasp of OOP.

What should you do to be prepared?
If you don't already have Apple's developer tools installed, go get them! You can go to Apple's Developer site and sign up to get the latest version. Part of the installation will place the developer documentation on your hard drive - it's worth bookmarking the page at /Developer/Documentation/Cocoa/CocoaTopics.html, since we'll be using the documentation there on a regular basis. Many of the links I'll provide will assume that you have the developer documentation available at /Developer/Documentation

It's a good idea to look over the documentation under the heading of "Objective-C Framework Reference", both the Application Kit and Foundation categories. This is where you'll find all the classes that make up Cocoa; having a rough idea of what's there will make finding the class you need for a given task easier. A limited number of the simpler items in Cocoa aren't full fledged classes, but are implemented as structures. This means you use and access them with a different syntax from the Cocoa classes. You can find information on them here and here. If you're set to go, move on to the introduction.

How will this be organized?
The tutorials will start out simply, by coding a couple of small utilities without a GUI, and work up to a full GUI-based Cocoa application. The projects will be separated into topics, each of which will introduce the use of one or two Cocoa classes or techniques within the context of completing a necessary function within the projects. I'll try to post a new topic once a week. Once a topic is covered in one place, all future tutorials will assume that you know what you're doing in regards to the subject, so it's worthwhile going through the tutorials in a linear fashion. In response to feedback, I'll update these tutorials to clarify or correct any mistakes I've made, so there may be occasions where you'll want to go back to an earlier tutorial - keep watching the table of contents for new modification dates. In addition, I could possibly take requests - if there are any programs that you'd find useful or any problems that have you stumped, please let me know, and I'll try to fit them into the structure of these tutorials

So, if you're still reading, it's time to get into some of the details of the language and techniques we'll be using. Tomorrow we will be looking at the introduction and we will cover a little of Objective-C, and then get into details on how to find info on Cocoa programming and what to do when your code goes bad.

If you have any questions or comments about this article, feel free to e-mail me at john_timmer@osxfaq.com

Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.