我正在学习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的data:images上:
Implicit conversion of Objective-C pointer type 'NSMutableArray *' to C pointer type 'void *' requires a bridged cast
我试图将其修复无济于事。我该怎么办?我尝试将void *更改为NSMutableArray,但仍然没有帮助。如何桥接演员?我尝试使用
__bridge
,但它说您无法桥接强制转换NSMutableArray。 最佳答案
尝试替换此 call :
[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;
关于objective-c - ARC和cocos2d中的桥接浇铸,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11641607/