Moving An Object With Touch

for(touch in iPhoneInput.touches) {
     if(touch.phase == iPhoneTouchPhase.Moved || touch.phase == iPhoneTouchPhase.Began) {
          transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y, 10));
     }
}

I have found the above code from tutorial Moving An Object With Touch but its not working when I play game in Unity3D. Can some one please help me.

// Update is called once per frame
void Update () {

	foreach(Touch touch in Input.touches) {
		if(touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Began) {
			transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y,10));
		}
	}

}