views:

51

answers:

1

Some time ago I developed an app for a client. It's basically a simple calculator. Because they like it so much they asked me if it would be possible to create dashboard widget with the same functionality based on the iPhone app.

I have never before developed a widget, I only know that they are mostly html + css based, so this raises a few questions for me:

  • Is using html + css the only way to create a widget?
  • If no:
    • Can XCode be used to create a widget?
    • Is it possible to wrap Cocoa applications into a widget?
  • If yes, are there any convenience tools to create a Cocoa-Touch-like look, feel and functionality (especially of tableviews)?

I guess the superquestion to all the above questions would be: Is there any chance I can reuse some parts of the existing iPhone project or do I need to create the widget from scratch?

Thanks alot!

+1  A: 

In your /Developer/Applications/ directory, you find *Dashcode which might help you develop a Dashboard widget.

Yes it's mostly HTML+CSS. You can add a Cocoa plug-in, as described here. However, that Cocoa plug-in can't draw using Cocoa methods onto the webview of the widget.

You can create a webkit plugin as described here, which can draw using Cocoa methods onto the webview of the widget. You can package them inside a widget.

However, the Cocoa methods you can use are AppKit methods, not UIKit methods. Specifically, you don't have UITableView, you have NSTableView which are rather different beast.

The logic parts using Foundation objects can be reused, but I would guess it's a big rewrite. It might be easier and less time-consuming to rewrite everything in terms of html + javascript + css.

I hope Apple add an iOS emulation layer in OS X 10.7, so that you can load an iPhone app to the dashboard. That would be awesome, if Apple can find a way to emulate the touch events nicely...

Yuji