Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Mac Tips and Tricks

Get all Mac OS X Tips, Tricks, Tutorials, Hacks, Support, Downloads, Updates...right in to your Mac OS X Mountain Lion, Lion, Snow Leopard, Leopard or Tiger Dashboard !
Learn How To using Finder, Preview, iChat, iCal, Mail, Safari, Address Book, Expose, Dock, Dashboard, Spotlight, Keyboard Shortcuts...or Customizing Your Mac !
↓ Download

WebKit Projects

There are many exciting projects that we are actively working on in the WebKit source tree. To find out more about each project you can visit that project's home page. If you are interested in starting a new project in the WebKit tree, contact WebKit.org!

General Projects

Web Site Compatibility
The most important project that we are working on (and the one that receives the most attention) is web site compatibility. Our top priority is ensuring that WebKit works with as many web sites as possible. This is a cross-functional project that touches many areas of the code.

Performance
Our second highest priority after compatibility is performance. Find out about our performance measurement tools and policies here.

Code Cleanup
We have a number of tasks in mind for code cleanup. In addition to reformatting existing code to match our coding style guidelines, we also have plenty of work to do moving WebKit code into WebCore now that both frameworks are open source.

Portability
Making the WebKit code more portable to other platforms is also a priority. We would like to begin integration of ports to other platforms, such as the GTK+ port of WebCore. Find out about our plans here.

Documentation
Want to add documents to the WebKit web site? We're interested in architecture documents, support charts and any other documents you think will help people trying to use WebKit.

Specific Projects

CSS (Cascading Style Sheets)
Cascading Style Sheets (CSS) is a simple mechanism for adding style to Web documents. It is a W3C standard.

DOM (Document Object Model)
The Document Object Model is a platform and language neutral interface that allows code to dynamically access and update the content, structure and style of documents. It is a W3C standard.

HTML/XHTML (HyperText Markup Language)
The HTML project is concerned with the implementation of the HTML and XHTML specifications from the W3C. In addition to the W3C work on HTML and XHTML, we are also interested in the extensions to HTML proposed by the WhatWG in the Web Apps specification.

HTML Editing
The HTML editing project provides rich text editing capabilities both as WebKit API for applications and through support of contentEditable and designMode for use in Web pages.

HTML Forms
The HTML form controls project is about the code to support the form controls that are available in HTML and XHTML. We would like to extend forms to support the work of the WhatWG (in particular the Web Forms specification). We also plan to change how the forms are implemented in order to improve performance and portability of the controls.

JavaScript
JavaScript is the primary scripting language of the Web, and WebKit's JS engine is one of the fastest out there. Find out about some of the interesting improvements planned for the JavaScript interpreter.

Layout and Rendering
For work on the layout and rendering of XML/HTML+CSS. This includes block and line layout, table layout and extensions like the XUL box layout. This also includes work on rendering and display issues.

MathML

MathML is a specification for the inclusion of mathematical expressions in Web documents. Although this is not yet implemented in WebKit, we are keenly interested in developing a fully integrated implementation.

Plug-ins
WebKit supports two types of plug-ins, cross-browser plug-ins using an enhanced form of the Netscape plug-in API and WebKit plug-ins that are designed for use by embedded applications that need to display native OS X content integrated with the Web document.

Printing
Find out about WebKit's printing architecture here and about planned improvements to make page breaks work more cleanly when splitting up objects like HTML tables.

SVG (Scalable Vector Graphics)
SVG is a standard from the W3C for describing two-dimensional graphics for Web documents. This is not yet implemented in WebKit, but we are very interested in merging KSVG and the KDOM work into our code base to achieve a fully integrated SVG solution. If you want to see Dashboard widgets that use SVG, come on in and help make it happen!

WebKit API
The WebKit embedding API provides clients with a public API for loading, displaying and manipulating Web content. WebKit clients can find out about plans for the API and get involved in the design process.

Web Page Accessibility
WebKit has accessibility features designed to work with the VoiceOver technology of OS X. Get involved and make suggestions for how this support can be improved in future releases. We are also interested in how to generalize our current accessibility support to make it portable to other platforms.

XML (Extensible Markup Language)

XML is the foundation of WebKit's document object model and in the future will be the preferred format for compound documents that use HTML, SVG and MathML together. This project covers the implementation of XML in WebKit and also other XML-related technologies like XPath.

XSLT

XSL Transformations provide the ability to take source XML and transform it into text, HTML or XML. This capability is a recent inclusion in WebKit, and there is still lots of interesting work to do in this area.

Base SDK Missing


For the noobie iPhone App Developer, their reaction to the error message “Base SDK Mssing” on an xCode sample code project, is similar to how I once felt about the “Blue Screen of Death” on a PC.

I got that same feeling of frustration when I loaded down the PageControl sample code from Apple. I couldn’t test the sample code in xCode because the “Base SDK Missing” error message was on display. I was using xCode 3.

It wasn’t the first time I’d come across this error, however, previously I’d found a solution.  I was desperately seeking a solution to paging horizontally and having PageControl.

I’ve solved my problems with the “Base SDK Missing” error message by trawling the internet and finding many generous people who share their knowledge.  So this “post” is me giving back to the app development community a little of what I’ve learned.

Solving the “Base SDK Missing” Error

Sometimes you will try to open an old xCode project and you will find you can’t open it because the file gives you a “Base SDK Missing” message, as shown in the image below:

 Base SDK Missing error message as seen on the xCode Dashboard

The first time I came across this problem I was working through John Ray’s Book “iPad Application Development in 24 hours”. The problem raised its ugly head again when I tried to open the PageControl sample code from Apple.

I came across the problem again when I found an article about sample code titled “How to Add A Slick iBooks Like Page Turning Effect Into Your Apps”, published by Johann “John” Dowa on his website ManiacDev. The article led me to a download for an xCode project called Leaves created by Tom Brow and an extension of the same project called “Leaves Two Pages” by Ole Begemann.

I couldn’t open the projects because they gave an error message i.e. Base SDK Missing.  As mentioned, I’d had this message before but when I applied my solution, Solution 1, shock horror, it didn’t work.  So I hunted around the internet for more solutions and found Solution 2.  Both solutions are set out below:

Solution One for xCode 3
1) Select xCode File Name in the left side navigation bar and click on the blue Info button on the xCode Dashboard and a drop down menu will appear showing several tabs.

Screenshot showing selection of xCode File Name


xCode Dashboard Info Button

xCode Dashboard

2) Click on the Build Tab

Info Button Drop Down List showing Build Tab

3) Find “Base SDK” under Architecture section and select the appropriate version e.g. 4.2
4) Scroll down to Deployment Section and also set “OS Deployment Target” as 4.2
5) Close the xCode Project (do not close the xCode Program) then reopen the Project

This solution came partly from a member of the iPhone SDK Development Forum and a little tweaking by me.

If this did not fix the problem then follow the steps in solution two, as follows:
Sometimes, if the test file has been created in a very old xCode Program,  you need to take more steps.
A solution for this problem was solved by a member of the “Leaves Developers” Google Group.

Solution Two
1) In xCode go to Targets and right click over the file name and select “Get Info”

Target Get Info Drop Down Menu

2) A drop down list will appear. Go to the Architecture section and click on the Base SDK Value field and select the correct iOS.

Target Architecture Drop Down Menu

3) Close the xCode Project (do not close the x Code program) and reopen the project.  Hopefully you will then see that the Base SDK Missing message has disappeared and you are seeing “Simulator …

Simulator Button on the xCode Dashboard

Xcode Development



NSTableView class to create a single column table view

1. Create an Xcode project
  • Step 01: Launch Xcode 3.0 and create a new project by clicking on File ⇒ New Project.
  • Step 02: Select Application ⇒ Cocoa Application and click on the Next button.
  • Step 03: Specify the Project Name and Project Directory as follows:
  • Project Name: SingleColumnTableView
  • Project Directory: ~/Documents/Project/XCode/Tutorial/SingleColumnTableView/
  • Click on the Finish button.
This will bring up the Project window.

2. Edit the NIB file
  • Step 01: In the Groups & Files browser, expand the NIB Files folder and double click the MainMenu.nib file.
This will launch the Interface Builder application and open the following windows:
  • a. Interface Builder NIB file browser
  • b. Interface Builder Inspector
  • c. Interface Builder Library
  • d. Application Main Menu window
  • e. Application Window

3. Create a controller class
  • Step 01: Use Xcode to create the application controller class. In the Groups & Files browser, right click on the Classes folder ⇒ Add ⇒ New File.
  • Step 02: Select Cocoa ⇒ Objective-C class and click on the Next button.
Specify a name for the application controller class and click on the Finish button.
  • Filename: ApplicationController.m
You should now be able to see the files for the ApplicationController class will be automatically added to the Xcode project.

Double click on the ApplicationController.h file to view its interface specifications.

Double click on the ApplicationController.m file to view its implementation details.
  • Step 03: Click on the Interface Builder icon to bring it to the foreground. Using the Interface Builder Library, select Objects & Controllers ⇒ Controllers ⇒ NSObject and drag it to the Interface Builder NIB file browser.

Using the Interface Builder Inspector, specify the following information:
  • Class Identity ⇒ Class: ApplicationController
  • Interface Builder Identify ⇒ Name: ApplicationController
Because Interface Builder is automatically synchronized with Xcode, you can see the ApplicationController class that was previously created in Xcode, in the drop-down list box for the class identify.

You should now be able to see the reference to the ApplicationController class in the NIB file browser as shown below.
  • Step 04: Specify an action that the application controller class can respond to.

Go to Class Actions, click on the button and specify an action called update:
  • Step 05: Specify an outlet that will be used by the application controller class to communicate with the target table view object.
Go to Class Outlets, click on the button and specify an outlet called tableView.

Leave the tableView type as id for the moment. The tableView type will be changed to NSTableView later on.

4. Create a table view and link it to the application controller class' outlet
  • Step 01: Using the Interface Builder Library, click on the Objects tab and select the Views & Cells ⇒ Data Views folderr
  • Step 02: Drag and drop an NSTableView object from the library to the application window. Resize the NSTableView object so that it is correctly positioned within the window. Leave a little space at the bottom of the window, so that we can later on, add a button to update the table view contents.
  • Step 03: Since we're going to create a single column table view, we will need to delete the second table column using the Interface Builder NIB file browser.
Expand the Window (Window) object till you reach the Table View node.

Select the second Table Column and delete the object using the menu option Edit ⇒ Delete.

Your application window should now contain a single column table view.
  • Step 04: Slowly click on the NSTableView object twice, to select the Table View object.
The first click will select the Scroll View object and the second click will select the Table View object. The Table View will be highlighted as shown below.

Ctrl+drag from the Table View object to the ApplicationController class to specify its dataSource and delegate outlets.

Right click on the Table View object to check the newly created associations for its dataSource and delegate outlets.
  • Step 05: Select the ApplicationController class and ctrl+drag to the Table View object to its tableView outlet.
Right click on the ApplicationController class to check the newly create association for the tableView outlet.

Using the Interface Builder, change the type for the tableView outlet to NSTableView.


5. Create a button and link it to the application controller class' update action
  • Step 01: Using the Interface Builder Library, click on the Objects tab and select the Views & Cells ⇒ Buttons folder.
  • Step 02: Drag and drop an NSButton from the library to the application window.
Select the button and click on it once to rename it to Update.
  • Step 03: Select the Update button and ctrl+drag to the ApplicationController class in the Interface Builder NIB file browser.
Right click on the ApplicationController class to check the newly create association for the update: action.


6. Automatically generate source code and merge changes for the ApplicationController class
  • Step 01: Select the ApplicationController in the Interface Builder NIB file browser and click on File ⇒ Write Class Files.
Browse to the folder: ~/Documents/Project/XCode/Tutorial/SingleColumnTableView
Click on Save.
Click on Merge. This will launch the FileMerge utility.
  • Step 02: Merge changes to the ApplicationController.h file.
Select the ApplicationController.h file using the FileMerge utility.
This will show the ApplicationController.h source code differences between the
  • a. new source code that we just automatically generated using Interface Builder, on the left hand side
  • b. previous source code that we had initially generated using Xcode, on the right hand side
  • Difference #1: Select the first difference by pressing the ↓ down arrow key. We want to keep the changes on the right side so, press the → right arrow key. Alternatively, you can use the Actions drop down list to choose the difference to be selected for inclusion in the final merge.
  • Difference#2: Select the difference on the left, since we don't want the extra line break.
  • Difference#3: Select the difference on the left, since we want the IBOutlet NSTableView *tableView; entry to be included in the final merge.
  • Difference#4: Select the difference on the left, since we want the - (IBAction)update:(id)sender; entry to be included in the final merge.
Save the merge by clicking on File ⇒ Save Merge. You should see a green tick mark next to the ApplicationController.h file.
  • Step 03: Merge changes to the ApplicationController.m file.
Select the ApplicationController.m file using the FileMerge utility.

This will show the ApplicationController.m source code differences between the
  • a. new source code that we just automatically generated using Interface Builder, on the left hand side
  • b. previous source code that we had initially generated using Xcode, on the right hand side
  • Difference #1: Select the difference on the right.
  • Difference#2: Select the difference on the left, since we don't want the extra line break.
  • Difference#3: Select the difference on the left, since we want the - (IBAction)update:(id)sender; entry to be included in the final merge.
Save the merge by clicking on File ⇒ Save Merge. You should see a green tick mark next to the ApplicationController.m file.

Combine the files by selecting Merge ⇒ Combine Files.

Open the ApplicationController.h file to view the merged changes.

Open the ApplicationController.m file to view the merged changes.


7. Add a data source for the table view
  • Step 01: Open the ApplicationController.h file and add a data source.
Add the following lines of code just after the interface declaration:
  • // Data source
  • @private NSMutableArray *aBuffer;

8. Implement NSTableView protocol methods for displaying table view contents
  • Step 01: Implement the protocol method to retrieve the total number of rows in a table view.
Add the following lines of code to the ApplicationController.m file:
  • - (int)numberOfRowsInTableView:(NSTableView *)tableView{
  • return ([aBuffer count]);
  • }
  • Step 02: Implement the protocol method to retrieve the object value for a table column.
Add the following lines of code to the ApplicationController.m file:

  • - (id)tableView:(NSTableView *)tableView
  • objectValueForTableColumn:(NSTableColumn *)tableColumn
  • row:(int)row{
  • return [aBuffer objectAtIndex:row];
  • }

9. Implement the Update button handler
  • Step 01: Implement the ApplicationController update: method to print a log message to a console window and add a string object to the table view.
Add the following lines of code to the update: method in the ApplicationController.m file:
  • - (IBAction)update:(id)sender {
  • NSLog(@"The user has clicked the update button");
  • [aBuffer addObject:@"HelloWorld"];
  • [tableView reloadData];
  • }

10. Implement the awakeFromNib and dealloc methods
  • Step 01: In the awakeFromNib method, implement code to create and allocate memory for a new mutable array object.
Add the following lines of code to the ApplicationController.m file:
  • - (void)awakeFromNib{
  • aBuffer = [NSMutableArray new];
  • [tableView reloadData];
  • }
  • Step 02: In the dealloc method, implement code to release memory allocated to the mutable array object.
Add the following lines of code to the ApplicationController.m file:
  • - (void)dealloc{
  • [aBuffer release];
  • [super dealloc];
  • }

11. Build and run the application
  • Step 01: Display the Xcode console window by clicking on Run ⇒ Console.
  • Step 02: In the Xcode project window, click on the Build and Go icon to build and launch the application.
  • Step 03: Click on the Update button. This will create a row entry in the table view.
View the resulting log messages on the console window.

Document version: 1.0
Document date: 2008-03-08
Document reference: XCT_NSTVSC-1.0


Development tools: Xcode 3.0, Interface Builder 3.0.
Operating system: Mac OS X 10.5.2 (Leopard)


Handling button events

1. Create an Xcode project
  • Step 01: Launch Xcode 3.0 by clicking on the Xcode application icon.
  • Step 02: Click on File ⇒ New Project
  • Step 03: Select Application ⇒ Cocoa Application and click on the Next button.
  • Step 04: Specify the Project Name and Project Directory as follows:
Project Name: HandlingButtonEvents
Project Directory: ~/Documents/Project/XCode/Tutorial/HandlingButtonEvents/

Click on the Finish button.

This will bring up the Project window.

2. Edit the NIB file
  • Step 01: In the Groups & Files browser, expand the NIB Files folder and double click the MainMenu.nib file
This will launch the Interface Builder application.

The Interface Builder (IB) application will display a set of windows for developing a Human Machine Interface (HMI):
  • a. Interface Builder NIB file browser
  • b. Interface Builder Inspector
c. Interface Builder Library
d. Application Main Menu window
e. Application Window

3. Create a controller class
  • Step 01: We will now use Xcode to create the application controller class. In the Groups & Files browser, right click on the Classes folder ⇒ Add ⇒ New File.
  • Step 02: Select Cocoa ⇒ Objective-C class and click on the Next button.
Specify a name for the application controller class and click on the Finish button.

Filename: ApplicationController.m

You should now be able to see the files for the ApplicationController class will be automatically added to the Xcode project.
Double click on the ApplicationController.h file to view its interface specifications.

Double click on the ApplicationController.m file to view its implementation details.
  • Step 03: Click on the Interface Builder icon to bring it to the foreground. Using the Interface Builder Library, select Objects & Controllers ⇒ Controllers ⇒ NSObject and drag it to the Interface Builder NIB file browser.
Using the Interface Builder Inspector, specify the following information:

Class Identity ⇒ Class: ApplicationController
Interface Builder Identify ⇒ Name: ApplicationController

Because Interface Builder is automatically synchronized with Xcode, you can see the ApplicationController class that was previously created in Xcode, in the drop-down list box for the class identify.

You should now be able to see the reference to the ApplicationController class in the NIB file browser as shown below.
  • Step 04: Specify an action that the application controller class can respond to.
Click on the button and specify an action called update:

Using Interface Builder, click on File ⇒ Write Class Files to to update the source files for the application controller class.

Click on the Save button.

Click on the Replace button to overwrite the existing application controller class files.

Double click on the ApplicationController.h file from the Xcode project browser window.

Observe the newly added action method entry in the interface file
  • - (IBAction)update:(id)sender;
Double click on the ApplicationController.m file from the Xcode project browser window.

Observe the newly added action method implementation entry in the implementation file
  • - (IBAction)update:(id)sender {
  • }
  • Step 05: Implement the update action method for the application controller class.
As an example, add code to the ApplicationController.m implementation file to print a debug log message to a console window.
  • - (IBAction)update:(id)sender {
  • NSLog(@"The user has clicked the update button");
  • }

4. Create a button and link it to the application controller class' update action
  • Step 01: Using the Interface Builder Library, click on the Objects tab and select the Views & Cells folder.
  • Step 02: Drag and drop an NSButton from the library to the application window.
Select the button and click on it once to rename it to Update.
  • Step 03: Select the Update button and ctrl+drag to the ApplicationController class in the Interface Builder NIB file browser.
Select the update: in the Recieved Actions pop-up window.

Select the Update button and view the button connections using the Interface Builder Inspector.

Select the ApplicationController class from the Interface Builder NIB file browser and view the application controller class connections.


5. Build and run the application
  • Step 01: Display the Xcode console window by clicking on Run ⇒ Console
This will bring up the Xcode console window.
  • Step 02: In the Xcode project window, click on the Build and Go icon to build and launch the application.
This will launch the application window.
  • Step 03: Click on the Update button.
View the resulting log messages on the console window.

Keyboard Shortcuts

  1. Alt-⌘-Up to alter between .m and .h file
  2. ⌘-Shift-D, When you want to open a file or a symbol definition that’s in your project or in a framework.
  3. ⌘-Shift-E expand the editor view to full height of the window.
  4. Alt-⌘-Left / Alt-⌘-Right, Navigate among open files back and forth.
  5. Press Tab to accept the current completion.
  6. Escape presents a pop-up list from which you can select from all the available completions (i.e after dot press Escape to list down a complete list).
  7. Control-comma to show the list of available completions, Control-period to insert the most likely completion, and Control-Slash & Shift-Control-Slash to move between place holder tokens.
  8. ⌘-double click on a symbol to see the definition of a symbol.
  9. Option-double click on a symbol to see the documentation for that symbol– OR– Right click on any word and select ‘Find Selected Text in API Reference’ to search the API for that word.
  10. Cmd-/ to automatically insert “//” for comments.
  11. Ctrl+Left/Right Arrow to do intra-word text navigation.
  12. Control-1 list down all the project files.
  13. Control-2 to access the popup list of functions/methods/symbols in this file.
  14. Control-3 list down all the include files
  15. Right click on a variable in your function and click edit all in scope (Best one).
  16. ⌘-[ and ⌘-] to indent and unindent selected text. Makes cleaning up source code much easier.
  17. Double-click on the square brackets or parentheses to obtain bracket and parentheses matching.
  18. Control-Shift-R to show the Console
  19. Control-Alt-⌘-R to clear the log
  20. Control-⌘ Left/Right to fold and unfold the function.
  21. Shift-⌘-C, the class browser in Xcode.
  22. ⌘-=, Jump to the next error in the list of build errors. Display the multiple Find panel with ⌘-Shift-F.
  23. ⌘-O, Jump to the Project tab, to the build tab with ⌘-Shift-B and to the debug tab with ⌘-Shift-Y.

      Sample Codes for Dashcode !


      Dashboard is a display and management system for Mac OS X desktop utilities, called widgets. Developers can create widgets, such as a clock or a calculator,
      to provide functionality that doesn't require the complexity of a large application.

      Dashcode Sample Codes:

      Hello World
      Introductory Dashboard widget example
      (HTML)
      (DMG)
      (ZIP)

      Fortune
      Deprecated - Demonstrates use of a widget plug-in
      (HTML)
      (DMG)
      (ZIP)

      Scroller
      Dashboard widget with a DHTML scrollbar implementation
      (HTML)
      (DMG)
      (ZIP)

      Birthdays
      Dashboard widget with a plug-in that queries AddressBook.framework for contacts with upcoming birthdays
      (HTML)
      (DMG)
      (ZIP)

      Fader
      Demonstrates fading of elements inside a Dashboard widget
      (HTML)
      (DMG)
      (ZIP)

      Goodbye World
      Demonstrates display and use of widget preferences to save a widget's state
      (HTML)
      (DMG)
      (ZIP)

      Hello Welt
      Demonstrates localization techniques for Dashboard widgets
      (HTML)
      (DMG)
      (ZIP)

      Voices
      Demonstrates use of the widget.system command from Dashboard
      (HTML)
      (DMG)
      (ZIP)

      Resizer
      A widget that demonstrates how to use the Apple Animation and Animator classes.
      (HTML)
      (DMG)
      (ZIP)

      Syncer
      A widget that demonstrates how to use handle a Dashboard Sync event.
      (HTML)
      (DMG)
      (ZIP)

      Dashboard 10.4 Tiger Tips !

      Change the Dashboard shelf's background image:
      In 10.4, when you press the '+' symbol in the bottom left corner while Dashboard is active,
      the Dashboard shelf slides up into view containing all your widgets.
      The background image used for the shelf can be found here:

      ...System/Library/CoreServices/Dock.app/Contents/Resources/perf.png

      You can replace this image with any PNG image you like and it'll be tiled, or you can use a single, full width image.
      The shelf is 118 pixels high and as wide as your monitor (1024 pixels in my case),
      so you can use those dimensions to construct your own shelf background.
      The bottom area (where the widget names appear) will need to be lighter in color for best results,
      as the text is both light and shadowed.
      The height of the text area is 14 pixels.
      Note also that you do not need to make your PNG file the full width of your monitor --
      the image will repeat horizontally if it's not full-width.

      I used a tiny 2KB PNG to create the above full shelf background.


      Speed up Dashboard by clearing out its cache:
      Over the course of the past few months, Dashboard had become painfully slow for me,
      sometimes taking 10 to 20 seconds to load.

      I took a look at:


      ~/Library/Caches/ DashboardClient


      ...and found that the Dashboard cache was 20MB !!!.
      This seemed excessive (plus, I had a fairly recent backup), so I took a gamble and deleted all the files in the DashboardClient folder. Dashboard now loads almost instantaneously for me.


      Quickly free memory used by Dashboard widgets:
      If you only use Dashboard on rare occasions, and don't want all those widgets to stay running forever,
      try the following AppleScript:
       
      tell application "Dock"
      quit
      launch
      end tell


      This will relaunch the Dock and, since all the Dashboard widgets are subprocesses of the dock, they will be closed. Widgets will stay closed until Dashboard is invoked again.

      This is a handy way to quickly free up the RAM used by open Dashboard widgets.
      Run it, and the RAM is released. Press F12 again after that, and you'll see that your open Widgets are all still open (you'll just have to wait through that slight delay as Dashboard 'activates' them again).

      Detach widgets from the Dashboard:
      If you'd like one of your Dashboard widgets to be available all the time, instead of only when you have activated Dashboard via F12, then activate the Dashboard dvelopment mode.
      Open the Terminal and type defaults write:

      com.apple.dashboard devmode YES
       
      ...and press Return. Then logout and log back in again.
      Now debugging mode is activated.

      To get a widget off of the Dashboard and onto your desktop, just do the following:
       
      1 - Activate Dashboard by pressing F12 (or whatever key you've assigned to Dashboard).
      2 - Begin dragging the widget.
      3 - Press F12 again, before letting up on the mouse button.
      4 - Drop the widget wherever you want it.


      You can do the same thing in reverse to drag the widget back onto the Dashboard. Also of interest: while a widget is frontmost, you can press Command-R to reload it. (This may be necessary if a widget is buggy and gets messed up somehow.) There's even a nifty Core Image-based twirl effect to accompany the reload. 


      However, I find it extremely useful -- there are certain widgets that you'd just rather see and use all the time, instead of only in Dashboard mode. Note that the widgets float above all windows, so this trick is most useful if you have some spare desktop space.

      To disable this mode, repeat the above command, but replace YES with NO, and then logout/login again. Note that you can also restart the Dock to make the changes take effect (the Dock controls the Dashboard).

      Widget Limbo !
      When you have dragged a widget out of the Dashboard layer you can make it go into Widget Limbo like this: press and hold the mouse button over the widget; do not move the mouse. Press F12. Release the mouse button.

      The widget will now belong outside (beneath) Dashboard, but only be visible (in a darkened state) when Dashboard is active. So it's not possible to close it nor move it. (Normally you can hold the Option key to close a widget).

      Refreshing a Widget

      To refresh a specific widget, click on the widget once, and hit Command + R.
      You'll notice a very cool "swirl" effect, which almost looks like a hurricane on a radar screen:

      Screenshot of OS X Dashboard
       

      Every widget you refresh will perform this "swirl" action, and subsequently refresh the widget content.
      If you're wondering what widget this was that I refreshed, it's the basic weather widget from Apple:


      Screenshot of OS X Dashboard
       

      If you manually click the "+" icon in the lower left corner of Dashboard view, your "widget toolbar" will appear along the bottom.

      Here you can add or remove widgets from display.


      To open this "widget toolbar," you can also hit Command + "+".

      That's Command and the "+" key at the same time. Hitting it again will close the "widget toolbar."
      This is not so much a keyboard shortcut, but a keyboard adjustment.

      If you hold down the "Option" key while in Dashboard view, and hover over a widget, you can manually remove the widget by clicking the "X" in the upper left corner of the widget.

      The "X" only appears when you move the mouse over each widget.

      This is quicker than opening the "widget toolbar" first, and then removing.



      Much like hitting Command + R refreshes a widget, hitting Command + I should provide info on the widget. (Only applicable for widgets that have a "back side" info panel.)

      Generic Ajax Widget

      As part of this article, I've included a generic Ajax widget that simply grabs a URL and parses out a small section of the DOM that I'm interested in.
      It’s a good jumping off point to get going with an Ajaxified widget.



      Getting Dashcode

      If you've got a recent version of Leopard or Tiger, the system Disks will contain Dashcode in the developer kit (it may be installed already in your /Developer/Applications directory).
      Apple did have Dashcode available for download, but since it expired in July (when Leopard was to come out) it’s no longer there.
      You can hunt around the Internet for a old mirror if you don't have the CDs.
      Once installed, it'll say it’s expired: just get Dashcode working again.

      Stability

      Broken Dashcode RenderDashcode is particularly ropy with Safari 3.
      With Safari 2 it’s much more stable. Since there is the occasional crash from Dashcode,
      I would recommend constantly saving your project as you're coding.
      I found more than 10% of the time, Dashcode would crash and result in a total loss of my code from the last save point.

      Also, I've noticed that dumping a lot to the run log, when viewing the log, can cause Dashcode to slow right down to almost hanging.
      Best to avoid dumping large amounts of HTML to the log.
      However - and this is a big one - the upside of programming with Dashcode is worth the risk of the crash, because it’s takes most work out of the design process.
      Since you're using it’s GUI to drag and drop your design and how the user will interact with it, rather than having to code the look and feel by hand.

      Designing Widgets

      The interface and the library component of Dashcode makes it possibly the strongest app for developing widgets. It’s 2 minutes work to create a glass effect on your widget, or to place the elements on the window and get going.
      I would strongly recommend studying other widgets, and reading through the Dashcode design recommendations as it’s easy to design a widget that works, but twice the work to design a widget that’s usable and works well.
      You'll find you can place widget-type objects on your widget, like scroll areas or gauges - but to handle them in the code isn't entirely intuitive, which is why the best source of understand how these interface elements work, is by opening up other widgets that already make use of the element.

      Controls

      Dashcode offers the easy integration of bespoke elements such as the scrollarea, gauges and other such sexy components.
      They're pretty easy to drop on to the widget from Dashcode, but until you're coding, they're not immediately obvious how they work.
      The help is limited, so I would recommend to develop by tutorial, in particular, look for the 'refresh()' methods - as this seems to be a fairly standard way to redraw objects.
      Full documentation for the Apple classes API is available, but it’s pretty clinical.


      Effects

      Although effects are available within the Apple classes, you'll need to implement them yourself.
      This is fairly limited to dynamic resizing of the widget, which is achieved using:

      window.resizeTo(x, y);
       
      If you are going to resize the widget dynamically, check out the Apple resizing examples too.
      I used this technique in my HTML entities widget to keep the widget small when it’s dropped in to the Dashboard, but to allow it to grow dynamically when the user searched for a particular HTML entity.
      You should be able to find easing effects code and examples if the built in Apple animation class doesn't suite your needs.

      Running system commands

      This is one of the few areas that’s well documented in the provided API.

      You can run system commands using the following type of command:

      widget.system('ps -auxww | grep ' + myCommand, null);
       
      What you should keep in mind, is that you can run any command through the system method. This includes Perl, Ruby, AppleScript and anything else that suits your needs.
      Using these commands I've recently been able to create a widget that queries Mail’s SQLite’s database via Perl.
      It was a case of running the system method and capturing the output (and in my case, eval'ing it from a JSON output).


      Ajax in the widget

      You widget supports a variation of the Ajax object (or rather xmlhttprequest object).
      This version isn't bound by the usual security constraints of a browser - most importantly, it can request content from any domain.
      To execute any Ajax requests from your widget, ensure you have the Allow Network Access attribute turned on - otherwise the Ajax will fail without any given reason.
      For example, you could use Ajax to pull your film page from IMDb and then parse the XML for the elements of interest.
      However, if you do want to pull some data from a web page and process it using the DOM returned you have to fiddle the request - in particular the responseXML will be null because the page being returned isn't text/xml - it’s text/html. You can do it using the following (in jQuery syntax):

      $.ajax({
      url: 'http://remysharp.com/example_page', // doesn't really exist!
      dataType: 'html', // important
      success: function (xml) {
      // convert the HTML to an XML DOM object
      var dom = getDOMfromXML(xml);
      alert(dom.getElementsByTagName('h1').length);
      }
      });

      function getDOMfromXML(xml) {
      var d = document.createElement('div');
      xml = xml.substring(xml.indexOf('<body') + xml.substring(xml.indexOf('<body')).indexOf('>')+1);
      xml = xml.substring(0, xml.indexOf('</body>'));
      d.innerHTML = xml;
      return d;
      }
       
      This getDOM function is pretty horrible - but it works. I tried using DOMParser and tried using Ajax local data trick and I tried using an iframe to inject the XLM - but neither would load the XML properly (in fact it would be blank).
      The iframe would not load properly because it was still loading the entire frame while I was trying to access it.
      You can see this in use in the generic Ajax widget or download the source Dashcode project.


      Widget Attributes


      The widget attributes are fairly self explanatory, but it’s worth knowing:
      • Allow Network Access is required for Ajax requests
      • Allow Command Line Access is required for running external programs, i.e. if you have a Perl script executing some arbitrary task

      If you intend to make your widget available in different languages, then this is the place to enter the different strings.

      The Inspector

      • Hide items from the default image to present a better widget when it’s installing. It can to keep the preview of your app looking clean.

      Debugging

      Dashcode comes with a log that can be viewed during run time.

      You have following debugging tools:
      • Breakpoints
      • Live stack traces
      • Evaluate window - to test commands

      To write to the log, you need to use alert("My debug message");.