In priview good work, but on Iphone - incorect

Please help me. This code:

function Update () {    
    var fingerCount = 0;
    for (var touch : iPhoneTouch in iPhoneInput.touches) {
        if(touch.phase==iPhoneTouchPhase.Ended)
        {
        var ray : Ray = Camera.main.ScreenPointToRay (touch.position);
        hits = Physics.RaycastAll (ray.origin,ray.direction,300);
        control_j(hits); <- this incorect work
        }
        if (touch.phase != iPhoneTouchPhase.Ended && touch.phase != iPhoneTouchPhase.Canceled)
        {
        fingerCount++;
        }
    }
    if(Input.GetMouseButtonDown(0))
    {
    ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    hits = Physics.RaycastAll (ray.origin,ray.direction,300);
    control_j(hits); <- this good work      
    }
}

Maybe i bad use iPhoneTouch. Why if i use mouse - good work, but if install on IPad or IPhone or IPod - bad work. Please help.

if(Input.GetMouseButtonDown(0))
{
    ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    hits = Physics.RaycastAll (ray.origin,ray.direction,300);
    control_j(hits); <- this good work      
}

This piece of your code responds to a mouseclick. This will not register on the Iphone since it does not handle input for a mouse. All code in it will never be used.

Comparing it with the other code sample doesn't make much sense to me since assuming that Iphone controls that are differently coded will work just because the mouse controls worked. This a dangerous assumption and can lead to design problems aswell because of corrupts the train of mind if done regularly.

Given the information you have supplied me with I can't help you with any more then that yet. Are you programming in script for Unity Engine only, or are you bringing along .NET? Why make a ray variable over and over in the for loop? What are you trying to achieve with the code , e.a. , what is it's preferred behaviour?

for Iphone I use (test on IPhone 3G, IPad, IPod):

for (var touch : iPhoneTouch in iPhoneInput.touches) {
    if(touch.phase==iPhoneTouchPhase.Ended)
    {
    var ray : Ray = Camera.main.ScreenPointToRay (touch.position);
    hits = Physics.RaycastAll (ray.origin,ray.direction,300);
    control_j(hits); <- this incorect work
    }
    if (touch.phase != iPhoneTouchPhase.Ended && touch.phase != iPhoneTouchPhase.Canceled)
    {
    fingerCount++;
    }
}

This function "control_j(hits);" use only hits variable.

for mouse I use (test on PC (Mac)):

if(Input.GetMouseButtonDown(0))
    {
    ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    hits = Physics.RaycastAll (ray.origin,ray.direction,300);
    control_j(hits); <- this good work      
    }

I need analog (Objective C XCode):

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

}