Sli*_*nky 2 objective-c core-foundation ios6
有人能告诉我为什么会泄漏吗?我正在使用CFRelease(),我认为它发布了CFURLRef soundFileURLRef
调用函数'CFBridgingRetain'返回一个Core Foundation对象,其中+1保留计数
对象泄露:在此执行路径中未分配对象,并且保留计数为+1
-(void) playGuitarNote:(NSString *)noteVal {
AudioServicesDisposeSystemSoundID(soundId);
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef = CFBundleCopyResourceURL(mainBundle,CFBridgingRetain(noteVal), CFSTR("aiff"), NULL);
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundId);
AudioServicesPlaySystemSound(soundId);
CFRelease(soundFileURLRef);
noteVal = nil;
}
Run Code Online (Sandbox Code Playgroud)
你不应该在CFBridgingRetain()那里打电话.你应该只使用一个__bridge演员:
CFURLRef soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(__bridge CFStringRef)noteVal, CFSTR("aiff"), NULL);
Run Code Online (Sandbox Code Playgroud)
您没有更改所有权noteVal,您只是传递它并告诉编译器将其视为不同(但兼容)类型.
| 归档时间: |
|
| 查看次数: |
1709 次 |
| 最近记录: |