Wo und wie __überbrücken
Ich brauche einen Rat__bridge
-in iOS.
Hoffentlich die SSCCE1 Im Folgenden wird das Problem besser erklärt, als ich es in Worten kann, aber ich muss wissen, wie ich ein konvertieren kannvoid*
zu einemNSMutableArray*
; welche__bridge
Variation sollte verwendet werden (siehe Kommentar im Code).
Als ich über die verschiedenen Brücken las, folgerte ich, dass ich sie brauchen würde__bridge_transfer
dann erhalte ich aber einen EXC_BAD_ACCESS amaddObject:
Letztendlich hätte ich gerne eine Reihe vonCGPoints
in demCGPath
nach demCGPathApply
genannt worden.
#import <Foundation/Foundation.h>
void _processPathElement(void* info, const CGPathElement* element)
{
NSMutableArray *array = (/* WHAT BRIDGE HERE */ NSMutableArray*) info;
switch (element->type)
{
case kCGPathElementMoveToPoint:
case kCGPathElementAddLineToPoint:
{
CGPoint point = element->points[0];
[array addObject:[NSValue valueWithCGPoint:point]];
break;
}
default:
break;
}
}
int main(int argc, char *argv[])
{
@autoreleasepool
{
//Create path
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint( path, NULL, 0, 0);
CGPathAddLineToPoint(path, NULL, 1, 0);
CGPathAddLineToPoint(path, NULL, 1, 1);
CGPathAddLineToPoint(path, NULL, 0, 1);
CGPathCloseSubpath(path);
NSMutableArray *pathPoints = [NSMutableArray array];
CGPathApply(path, &pathPoints, _processPathElement);
NSLog(@"Points:%@", pathPoints);
}
}
1:SSCCE