I'm trying to convert my code to Objective-C ARC and get several errors.
1.:
NSBezierPath *path = [NSBezierPath bezierPath];
CGPathApply(pathRef, pat开发者_C百科h, CGPathCallback); //error
It says: Implicit conversion of an Objective.C pointer to 'void *' is disallowed with ARC
2.:
static void CGPathCallback(void *info, const CGPathElement *element) {
NSBezierPath *path = info; //error
[…] }
It says: Implicit conversion of a non-Objective-C pointer type 'void *' to 'NSBezierPath *' is disallowed with ARC
Any ideas, how I can resolve the problems?
You need to use bridged casts. In this case, you just want the simple __bridge
modifier, e.g.
NSBezierPath *path = [NSBezierPath bezierPath];
CGPathApply(pathRef, (__bridge void *)path, CGPathCallback);
and
static void CGPathCallback(void *info, const CGPathElement *element) {
NSBezierPath *path = (__bridge NSBezierPath*)info;
...
}
精彩评论