我有一个每次调用时都会播放声音的方法:
- (void)play :(NSString *) fileName : (NSString *) extension
{
AUGraph theAUGraph;
...
AUGraphStart(theAUGraph);
...
[self performSelector:@selector(stopPlaying) withObject:theAUGraph afterDelay:5.0];
}
现在五秒钟后,选择器调用 stopPlaying 方法,并传递 AUGraph 对象:
-(void) stopPlaying: (AUGraph *) graph{
AUGraphStop(graph);
}
我马上遇到的问题是:
Implicit conversion of C pointer type 'theAUGraph' (aka 'struct OpaqueAUGraph *') to Objective-C pointer type 'id' requires a bridged cast.
我尝试了两个建议的修复:
[self performSelector:@selector(stopPlaying) withObject:(__bridge id)(theAUGraph) afterDelay:5.0];
和
[self performSelector:@selector(stopPlaying) withObject:CFBridgingRelease(theAUGraph) afterDelay:5.0];
但是在运行时它只是因EXC_BAD_ACCESS而崩溃
我很困惑,那我该如何传递对象呢?