Блоки в порядке, но как насчет написания массивов C?
Учитывая эту упрощенную ситуацию:
CGPoint points[10];
[myArray forEachElementWithBlock:^(int idx) {
points[idx] = CGPointMake(10, 20); // error here
// Cannot refer to declaration with an array type inside block
}];
после поиска в то время нашел это возможное решение, чтобы поместить его в структуру:
__block struct {
CGPoint points[100];
} pointStruct;
[myArray forEachElementWithBlock:^(int idx) {
pointStruct.points[idx] = CGPointMake(10, 20);
}];
это сработало бы, но есть небольшое ограничение, которое я должен создать динамический массив c:
int count = [str countOccurencesOfString:@";"];
__block struct {
CGPoint points[count]; // error here
// Fields must have a constant size: 'variable length array in structure' extension will never be supported
} pointStruct;
Как я могу получить доступ к массиву CGPoint
в block
?
ИЛИ
Возможно ли вообще вообще или мне нужно переписать метод блока, чтобы получить полную функциональность?