Flocked
Flocked

Reputation: 1890

Several problems with the Objective-C ARC conversion

I'm trying to convert my code to Objective-C ARC and get several errors.

1.:

NSBezierPath *path = [NSBezierPath bezierPath];
CGPathApply(pathRef,  path, 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?

Upvotes: 2

Views: 3546

Answers (1)

Lily Ballard
Lily Ballard

Reputation: 185811

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

Upvotes: 7

Related Questions