Question about touchesBegan


#1

Hi,

In the method touchesBegan:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    // Update linesInProcess with moved touches
    for (UITouch *t in touches) {
        NSValue *key = [NSValue valueWithPointer:t];
        
        // Find the line for this touch
        Line *line = [linesInProcess objectForKey:key];
        
        // Update the line
        CGPoint loc = [t locationInView:self];
        [line setEnd:loc];
    }    
    // Redraw
    [self setNeedsDisplay];
}

Why don’t we have to call [color=#008000][linesInProcess setObject:line forKey:key][/color] after [color=#008000][line setEnd:loc][/color]? If we have created the line object inside the loop, I don’t understand how the NSMutableArray lineInProcess is updated.

Thanks in advanced,
Gabriel