Uli's Web Site
[ Zathras.de - Uli's Web Site ]
Other Sites: Stories
Abi 2000
Stargate: Resurgence
Lost? Site Map!
     home | blog | moose | programming | articles >> blog

 Blog Topics

15 Most Recent [RSS]

 Less work through Xcode and shell scripts
2011-12-16 @600
 iTunesCantComplain released
2011-10-28 @954
 Dennis Ritchie deceased
2011-10-13 @359
 Thank you, Steve.
2011-10-06 @374
 Cocoa Text System everywhere...
2011-03-27 @788
 Blog migration
2011-01-29 @520
 All you need to know about the Mac keyboard
2010-08-09 @488
 Review: Sherlock
2010-07-31 @978
 Playing with Objective C on Debian
2010-05-08 @456
 Fruit vs. Obst
2010-05-08 @439
 Mixed-language ambiguity
2010-04-15 @994
 Uli's 12:07 AM Law
2010-04-12 @881
 Uli's 1:24 AM Law
2010-04-12 @874
 Uli's 6:28 AM Law
2010-04-12 @869
 Uli's 3:57 PM Law
2010-04-12 @867


Some Practical Tips for Cocoa Programming

Okay, so you've read the essential book on Cocoa programming, read the PDF on the Objective C programming language that tells you about Categories and Protocols, and you're now well into your second application and you wonder if there is no way to make this easier for you.

Surely, the pros aren't spending half their day Googling for "Cocoa this" and "Cocoa that", or fighting the navigation of Apple's Cocoa docs to find out what to do next, or to recover information you looked up yesterday and have already forgotten again?

Here's a few tips about essential shortcuts and handy tricks that make Cocoa development in xCode (and the 10.2 version of Project Builder) a pleasure:

  • xCode contains all of Apple's developer docs. See the "Help" menu for the Cocoa documentation. This window is a little on the slow side to come up, but works quite nicely when you leave it open in the background and be sure to always choose "Cocoa Help" and not xCode's help menu item (of course, reading xCode's docs and especially the FAQ is handy, too, but you usually only need to do that once, while Cocoa's docs are a constantly flowing source of enlightenment... sort of).
  • Want to know what methods a class has, or what parameters a function you're using rarely took again? Open its header file for a quick reminder. Use the Open Quickly... menu item and enter the name of its header file, and it'll come up in a snap. Typically this is the class name followed by ".h" (e.g. "NSString.h"), but the mutable versions usually go with their immutable counterpart (i.e. NSMutableSet is in "NSSet.h"). You can also select the name of any header file (e.g. as part of a #import statement) and choose Open Quickly... to have it jump there immediately.
  • Want the header or docs for a class, struct, constant, function or method, but don't remember what header it was in? Hold down the command key and double-click it to bring up the header. Hold down the option key instead to bring up the docs.
  • Your application has an error that throws an exception, but you don't know where it is actually being caused? Yeah, wish there were an ObjC-equivalent to the Break on C++ exception menu item...
    Well, you can do it manually in GDB: After your application has started up (e.g. set a breakpoint in main(), or click Pause in the debugger after it's loaded the frameworks), bring up the Debugger Console. You'll see a (gdb) prompt. Type:
    (gdb) fb [NSException raise]
    You're telling the Unix-style GDB debugger to set a breakpoint on NSException's raise method. As you'll probably know, this method is what's called whenever an exception is thrown (or raised in Cocoa parlance). As soon as someone raises an exception, your app will break into the debugger, and you can look at the stack backtrace and the variable list to find out where it actually occurred.
  • Looking for clarifications? Sample code? Tutorials? There are a few great places for that:

That's all that comes to mind right now. Let me know if you can think of any other cool tricks I've forgotten or which I maybe didn't even know yet.
Created: 2004-12-05 @699 Last change: 2004-12-05 @739 | Home | Admin | Edit
© Copyright 2003-2023 by M. Uli Kusterer, all rights reserved.