Access C Array within blocks (variable array count) Objective-C

后端 未结 2 801
走了就别回头了
走了就别回头了 2020-12-16 12:58

Blocks are fine but what about writing C arrays?

Given this simplified situation:

CGPoint points[10];
[myArray forEachElementWithBlock:^(int idx) {
          


        
2条回答
  •  温柔的废话
    2020-12-16 13:21

    Another simple answer which works for me is the following:

    CGPoint points[10], *pointsPtr;
    pointsPtr = points;
    [myArray forEachElementWithBlock:^(int idx) {
        pointsPtr[idx] = CGPointMake(10, 20);
    }];
    

提交回复
热议问题