开发者

iPhone Simulator Crash

I finished building a small 开发者_如何学编程app with audio, clicking "next" button will play a sound and take me to the next page, clicking "back" will play a sound and take me back to the previous page. But if I do the next, back twice, the simulator crashes and I receive the below message from the log. Anyone can help please, cheers. the message is: * Thread1: Programme received signal: "EXC_BAD_ACCESS" * while the code does compile well and I can turn the pages (41 in total).


This error is most always caused by trying to call a method on an object that has already been deallocated. One way to diagnose this issue is to use the Zombies template in Instruments. It will give you a dialog (with the call stack) when you message a deallocated object. No matter what the exact cause, this is most certainly related to your memory management.


This is a guess.

You said that it crashes if you click next, then back twice. I'm assuming that you keep the pages in an array, correct? If so, by clicking back twice you are trying to load a page with an index of -1. An array doesn't have an object at the index -1.

If I'm right, All you have to do is this:

// In the back button code:
if(currentPageIndex - 1 < 0) {
     // Dont go back
} else {
     // Go Back
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜