Dvole
Dvole

Reputation: 5795

Bridged cast in ARC and cocos2d

I'm learning cocos2d with some books, namely book by Pablo Ruiz, here is some code:

[next runAction:[CCSequence actions:[CCDelayTime
                 actionWithDuration:2], 
       [CCFadeIn actionWithDuration:1],
    [CCDelayTime actionWithDuration:2],
     [CCCallFuncND actionWithTarget:self selector:@selector(cFadeAndShow:data:) 
                                                    data:images],nil]];


- (void) cFadeAndShow: (id)sender data:(void*) data
    {
        NSMutableArray *images = data;
        [self fadeAndShow:images];

    }

And it gives me an error showing on data:images in runAction:

Implicit conversion of Objective-C pointer type 'NSMutableArray *' to C pointer type 'void *' requires a bridged cast

I tried fixing it to no avail. What should I do? I tried changing void* to NSMutableArray, still didn't help. How do I bridge cast? I tried using __bridge but it says that you can't bridge cast NSMutableArray.

Upvotes: 3

Views: 921

Answers (1)

danielbeard
danielbeard

Reputation: 9149

Try replacing this call :

[CCCallFuncND actionWithTarget:self selector:@selector(cFadeAndShow:data:) data:images],nil]];

with this:

[CCCallFuncND actionWithTarget:self selector:@selector(cFadeAndShow:data:) data:(__bridge void*)images],nil]];

Then in your fade and show method, cast it back to an id:

NSMutableArray *images = (__bridge id) data;

Upvotes: 3

Related Questions