The following instructable will show you how to build a guitar buffer and cable that will allow you to connect your electric guitar directly to your iPhone/iTouch's headphone/mic socket.
To build this instructable you'll need to know how to make a PCB (I used the toner transfer method) and some understating in basic electronics. You could also build it on strip board instead of making a PCB.
Step 1: Circuit Diagram of the Buffer.
The terminals I/P means input and O/P means output.
I haven't included the power diode in the circuit that prevents damage if you connect the battery around the wrong way. I'll show the diode in the wiring diagram.
Step 2: PCB
I've added an Eagle CAD brd file and a PDF file that has the PCB layout.
The circuit has unity gain so it's not a preamp just a buffer. The output of the buffer goes into a trimpot so you can adjust the level. Set this trimpot so as not to overload the iTouch/iPhone when your guitar is setup as if you were using a guitar amplifier.
When you first build the circuit, set this trimpot 1/2 way and adjust for the best sound.
The circuit presents around a 1k load into the iPhone so as to automatically switch the internal microphone off.
Step 3: Wiring It Up.
I have detailed the plug pin out wiring in the next step.
Step 4: The Plug.
Another source of a 4 pole plug can be found on some A/V camcorder or DVD cables. You need to check if they're wired correctly. Some cables have the coax shield connected to sleeve of the plug. If you use these types of cable, then the shield of the coax cable will be used as the microphone connection which will cause hum. So don't use these A/V cables unless you know how they're wired up.
I used an old Nokia cable that had three separate coax cables. Using this type of cable prevents crosstalk although any multicored shielded cable should work as long as the cables not too long.