开发者

Several problems with the Objective-C ARC conversion

开发者 https://www.devze.com 2023-04-12 17:59 出处:网络
I\'m trying to convert my code to Objective-C ARC and get several errors. 1.: NSBezierPath *path = [NSBezierPath bezierPath];

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;
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消