我想存儲我的touchesMoved值到NSArray我怎麼能存儲。現在我嘗試存儲我的觸摸移動值,但我不會打印價值。 這裏是我的代碼存儲touchesMoved價值NSArray在iPhone
- (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];
}
我把這種方法是這樣
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self];
[self initWithSize:currentPoint.x height:currentPoint.y];
}
我打印這樣
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSString *myArrayString = [xArray description];
NSLog(@"screeX:%@ ",xArray);
}
這個值,但餘did't得到,在我的控制檯輸出像素 我得到這樣的輸出
screeX:(
(
),
(
),
(
),
(
),
(
),
(
),
(
),
(
根據你的代碼,數組是分配每次whwn觸摸移動... – vishy 2012-02-08 06:23:25
@vishy告訴我我該怎麼做才能將該值存儲到數組中? – 2012-02-08 06:26:21
嘗試下面的答案,並讓我知道結果 – vishy 2012-02-08 06:39:48