Friday, June 27, 2008

Xcode Tips

1. Read the Xcode Workspace Guide, it is available after launching Xcode. It is under Help -> Xcode Workspace Guide

2. Make full use of Snapshots to keep different versions of the project. It is under File -> Make Snapshot

3. Make full use of code completion. It is under Xcode Preferences > Code Sense > Code Completion > Automatically Suggest _> immediate
Press esc key for auto suggestion

4. There are two ways to search for API reference from the Xcode text editor:
Option–double-click a symbol name
Select an expression and choose Help > Find Selected Text in API Reference

Command–double-click a symbol name
and goes to the header file (command-shift-w to close the header file)

5. Learn and use Refractor instead of Find & Replace

6. Use Project -> Class Browser

7. Use #pragma in source code to improve readability
To add a separator to the Function menu use:
#pragma mark -

8. Short Cut Keys in code editor
indent : Command-]
un-indent : Command-[
block select : Option key while clicking and dragging

9. Use this DEBUGLOG to replace NSLog

#ifdef DEBUGON
#define DEBUGLOG

In the project settings of Debug add this user-defined setting (under Debug)


Then, you can simply use DEBUGLOG(@"Testing output %.2f", myFloat); in your code
and in Debug Build NSLog will be used, but in Release Build or Distribution Build, no NSLog output.

No comments: