【发布时间】:2012-03-19 16:36:00
【问题描述】:
我想播放 NSSound 两次,除了短于 10 秒,然后我想等到 10 秒完成,然后再开始第二次。
但是我在播放同一个 NSSound 两次时遇到了问题。
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"MessageArrived" ofType:@"wav"];
NSSound *sound = [[NSSound alloc] initWithContentsOfFile:resourcePath byReference:YES];
[sound play] //It plays the fist time
[sound play] //I get the following Error and it doesn't play a secont time
/*malloc: *** auto malloc[498]: error: GC operation on unregistered thread. Thread registered implicitly. Break on auto_zone_thread_registration_error() to debug.*/
谁能告诉我这个错误的原因是什么? 我该如何处理?
我还有其他方法吗?
【问题讨论】:
-
好像你正在使用垃圾收集。如果可能的话,你应该把你的代码移到 ARC 上,很多框架在启用 GC 时有点脆弱。
-
我必须做些什么才能让 ARC 工作并禁用 GC?我在 ARC 可用之前就开始了这个项目......
-
新的 Xcode 4.3.1 在 Edit > Refactor 菜单下自动将项目从 GC 转换为 ARC。
-
好的,谢谢... 这样做修复了来自 GC 的消息,但没有修复声音播放问题。但是...我找到了导致问题的原因:)
标签: objective-c cocoa