Q:

store touchesMoved value to NSArray in iPhone

i want store my touchesMoved value in to NSArray how can i store that. now i try to store my touches moved value but i won't print value.
here is my code 
- (void)initWithSize:(int)nX height:(int)nY {
    xWidth = nX;
    yHeight = nY;

        xArray = [[NSMutableArray alloc] initWithCapacity:xWidth];

        for (int i = 0; i < xWidth; i++) {

            yArray = [[NSMutableArray alloc] initWithCapacity:yHeight];

            for (int j = 0; j < yHeight; j++) {                

            }

            roomArray = [[NSArray alloc] initWithArray:yArray];
            [xArray addObject:roomArray];
            [roomArray release];
            [yArray release];

        }

i call this method like this  
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];   
    CGPoint currentPoint = [touch locationInView:self];

    [self initWithSize:currentPoint.x height:currentPoint.y];

}

i print this value like this
   - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {   

        NSString *myArrayString = [xArray description];
          NSLog(@"screeX:%@ ",xArray);    
    }

but i did't get that pixels in my console output 
i got output like this 
screeX:(
        (
    ),
        (
    ),
        (
    ),
        (
    ),
        (
    ),
        (
    ),
        (
    ),
        (

A:

The way you are implement is not proper.

Declare a NSMutableArray object in .h file.
NSMutableArray *_array;

You can allocate the array in viewDidLoad.
_array = [[NSMutableArray alloc] init];

In touchesBegin, remove all the objects of the array.
[_array removeAllObjects];

In touchesMoved, add the CGPoints to the array as follows.
[_array addObject:[NSValue valueWithCGPoint: currentPoint]]; 

Now , in touchesEnded, print the array and see the values.

