0

呼び出されるたびにサウンドを再生するメソッドがあります。

- (void)play :(NSString *) fileName : (NSString *) extension
{
    AUGraph theAUGraph;
    ...
    AUGraphStart(theAUGraph);
    ...
    [self performSelector:@selector(stopPlaying) withObject:theAUGraph afterDelay:5.0];
}

5 秒後、セレクターは 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でクラッシュしました

私は混乱しています。どうすればオブジェクトを渡すことができますか?

4

2 に答える 2

2

AUGraphObjective-C オブジェクトではありません。

でボックス化することもできますが、NSValueそのコード行を への呼び出しに置き換えるだけですdispatch_after()(Xcode には、 の使用方法を示すテンプレートがありますdispatch_after)。

于 2013-06-09T21:04:38.407 に答える