This code is an idea about how to get the touched rectangles. For each new rectangle touched a counter will be added 1, so there is easier track the touch movement (if needed). For more accuracy, change the values for the constants ROWS and COLS
#define ROWS 15
#define COLS ROWS
int matrix[ROWS][COLS];
int squareCounter;
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    int col = floor((location.x * COLS) / self.view.frame.size.width);
    int row = floor((location.y * ROWS) / self.view.frame.size.height);
    if (matrix[col][row] == 0) matrix [col][row] = ++ squareCounter;
    [label setText:[NSString stringWithFormat:@"[%d][%d] -> %d", col, row, matrix[col][row]]];
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSString *matrixStr = @"";
    for (int i = 0; i < COLS; i++) {
        for (int j = 0; j < ROWS; j++) {
            matrixStr = [matrixStr stringByAppendingFormat:@"%d\t", matrix[j][i]];
        }
        matrixStr = [matrixStr stringByAppendingString:@"\n"];
    }
    NSLog(@"Matrix:\n%@", matrixStr);
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    squareCounter = 0;
    for (int i = 0; i < ROWS; i++) {
        for (int j = 0; j < COLS; j++) {
            matrix[i][j] = 0;
        }
    }
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}
It must be placed on the view controller whose view you want to detect the touch shape.