問題:
? ? ? ? 在使用AVAudioPlayer調用play(或prepareToPlay)進行音頻的播放(或預播放)時,竟然遭遇Crash。當時就一臉懵逼,這簡單的調用都會出錯!經過分析與資料查詢,原來是我加了那種習慣性的異常斷點(Exception Breakpoint)造成的。
? ? ? ? 對于這個問題,我在這里引用一下StackOverflow上的解答:
解答1:
Add your exception breakpoint and edit the exception type from "All" to "Objective-C exceptions"
Some classes in AudioToolbox throw regular C++ exceptions. You can filter them off this way.
解答2:
The problem was I normally develop with a breakpoint set to "All Exceptions", and the actual exception thrown was __cxa_throw.
Which apparently turns out to be in C++ libraries that are used to implement AVAudioPlayer.
By changing the breakpoint to "All Objective-C Exceptions" the program ran fine. (This can be done by editing the breakpoint and changing the Exception field to Objective-C.
總結:
? ? ? ? 總之,就是當兩者相遇時,Exception Breakpoint你還是做出點改變吧,將你的類型由默認的“All”改為“Objective-C”。這不,他倆這會兒算是平靜了,我也暫時輕松嘍。