我是否需要在Objective-C代码(带有ARC的iOS 6)中释放C变量?

ike*_*8me 2 c objective-c automatic-ref-counting ios6

如果我在iPhone代码中实现以下内容:

NSString* soundPath = [[NSBundle mainBundle] pathForResource:soundFile ofType:@"wav"];
SystemSoundID feedbackSound;
AudioServicesCreateSystemSoundID((__bridge CFURLRef) [NSURL fileURLWithPath:soundPath], &feedbackSound);
AudioServicesPlaySystemSound(feedbackSound);
Run Code Online (Sandbox Code Playgroud)

我是否真的必须释放"feedbackSound",因为它是C代码?它会泄漏吗?

我正在使用ARC/iOS 6.

ser*_*gio 5

你应该.正确的调用方法是:

AudioServicesDisposeSystemSoundID
Run Code Online (Sandbox Code Playgroud)

(参考).

通常,ARC仅处理Objective-C对象.当您处理较低级别的框架(核心图形,音频服务等)时,许多调用将在"引擎盖下"分配内存,由您负责处理.在许多情况下,您具有执行释放的特定方法,就像您进行分配一样.