문제

I want to have a 6 by 6 multidimensional array of CGpoints which will hold the vertex locations of 6 horizontal and 6 vertical lines. How would i do this?

도움이 되었습니까?

해결책

If you want to use NSArrays to do this, it would look something like the following:

NSMutableArray* topLevelArray = [NSMutableArray array];
for(int i = 0; i < 6; i++){
    NSMutableArray* innerArray = [NSMutableArray array];
    [topLevelArray addObject:innerArray];
    for(int j = 0; j < 6; j++){
        CGPoint point = CGPointMake(x, y);
        [innerArray addObject:[NSValue valueWithCGPoint:point]];
    }
}

Then, to access a point from your array:

CGPoint point = [topLevelArray[i][j] CGPointValue];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top