ARC和cocos2d的桥接演员

时间:2012-07-25 01:51:56

标签: objective-c ios cocos2d-iphone automatic-ref-counting

我正在学习cocos2d的一些书籍,即Pablo Ruiz的书,这里有一些代码:

[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];

    }

它给我一个错误显示数据:runAction中的图像:

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

我试图修复它无济于事。我该怎么办?我尝试将void *更改为NSMutableArray,仍然没有帮助。我如何跨接演员?我尝试使用__bridge,但它表示你无法桥接强制转换NSMutableArray。

1 个答案:

答案 0 :(得分:3)

尝试替换此次通话:

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

用这个:

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

然后在你的淡入淡出和显示方法中,将其强制转换为id:

NSMutableArray *images = (__bridge id) data;