If you are using Mac OS X Lion, see here
If you are using Mac OS X Leopard or Snow Leopard, see here
If you are using other Mac OS X Tiger or other version, see here
If you do not know which Mac OS X, download this tool, run it, it will tell you http://www.hanamobiles.com/tools/vnc/VNCMacConfig.zip
Troubleshoot:
1. If you are trying to connect to your office Mac computer or your Mac is behind a router, and your iPhone/iPad is not on the same local network. You need to modify router settings to add port forwarding to forward port 5900 to your Mac.
See here for details: http://portforward.com/routers.htm