The blocks are OK but what about writing C arrays?
Looking at this simple situation: After searching for some time, found this possible solution, put it in a straight: This will work but there are some limitations that I need to dynamically create a C: How can I get my OR Is it possible at all or do I have to type the block method again to get the full functionality? Maybe you can allocate arrays on the heap? CGPoint points [10]; [MyArray forEElementWithBlock: ^ (Int idx) {number [idx] = CG point make (10, 20); // error here can not mention declaration with an array type inside // block}};
__ block straight {CGPoint points [100]; } Point streak; [MyArray forEElementWithBlock: ^ (Int IDX) {pointStruct.points [idx] = CGPEXMake (10, 20); }];
int count = [str countOcurencesOfString: @ ";" ]; __blak straight {gg point number [count]; // Here there should be a static shape in the error // field: 'variable length array' structure in the structure will never be supported) pointStruct;
CGPoint array within a
block ?
// allocates a simple array to the heap. In the array there will be [myArray count] items, each size to fit a CGPoint. CGPoint * digits = [myArray count], sif (CG point)); // Make sure that the allocation is completed successfully, you want to handle some more flawed error here. NSParameterAssert (points! = Null); // loop on myArray, whatever you want, [myArray forEElementWithBlock: ^ (int idx) {points [idx] = "A" | | | }]; // Memory taken by C array is free of charge. Of course you probably want to do something else with the // array, otherwise this does not mean much to the effect: // free (points), points = zero;
Comments
Post a Comment