开发者

Easy way to trigger a noise in iPhone OS?

开发者 https://www.devze.com 2022-12-25 17:10 出处:网络
For example, the first gen iPod touch is making sharp tick sounds when rolling a picker view. I need a e开发者_运维技巧asy way to trigger a sound for my unit tests. When a unit test fails, I want the

For example, the first gen iPod touch is making sharp tick sounds when rolling a picker view. I need a e开发者_运维技巧asy way to trigger a sound for my unit tests. When a unit test fails, I want the iPhone simulator to make a noise so that I see it. Because I'm not looking at the console all the time for NSLog messages...


Rather than generating a sound in code, you might want to look at using breakpoints in the Xcode debugger that play audio.

To do this, create a breakpoint at the line in your code that you'd like to trigger the audio. Edit this breakpoint by right-clicking on the marker on the left and choosing the Edit Breakpoint menu item. You can then add an action for the breakpoint by clicking on the plus button under the breakpoint in the window that appears. Choose Sound as the type of action and pick from the list of possible sounds.

To make this breakpoint play, but not halt the execution of your application, click the checkbox on the right-hand side of this breakpoint in the list.

The following is an image of what this should look like when you're done:

Easy way to trigger a noise in iPhone OS?


(source: sunsetlakesoftware.com)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号