3

In my app, I have four buttons. When I press two of the four buttons, the app freezes. The weird thing is that no errors appear and there is nothing in the debugger window. I am new to iOS development, so I have no idea how to fix this. The app worked fine before the app started crashing, and I didn't alter any code, so I don't know what is going on. Can someone help me out?

Here is the code for where the button is pushed. It has been working fine, so I don't know why it doesn't work all of the sudden:

- (IBAction)showMapView:(id)sender
{
    P2OViewController *pvc = [[P2OViewController alloc]init];
    [self.navigationController pushViewController:pvc
                                         animated:YES];
}

- (IBAction)showTableView:(id)sender
{
    TableViewController *tableView = [[TableViewController alloc]init];
    [self.navigationController pushViewController:tableView
                                         animated:YES];
}

So I added global breakpoints, and nothing is happening. The app is still running, and the debugger navigator says it is still running. So I guess the app is freezing, and not crashing. I have no idea how to fix this.

Chandler De Angelis
  • 2,646
  • 6
  • 32
  • 45
  • 1
    You should post code, no one will ever get what the problem is like this. – IluTov Dec 30 '12 at 21:30
  • 1
    plz, add some code at least the -(IBAction) methods for your Buttons – Omarj Dec 30 '12 at 21:32
  • To fix this, first remove that poor unrelated 'xcode' tag from the question. –  Dec 30 '12 at 21:41
  • Did you check to make sure you didn't accidentally put a breakpoint down on those methods. A few times I have accidentally placed some, and it causes it too appear as if it crashed. That is probably not your problem, but worth ruling out. – Josiah Dec 30 '12 at 21:51
  • No I thought that too, but I check and made sure there wasn't any. – Chandler De Angelis Dec 30 '12 at 21:55
  • Applications dont ever just "crash" without giving you a reason, a stack trace, or a white screen of death. Check for all three, because if you aren't getting at least one then it's definitely a hardware problem. – CodaFi Dec 30 '12 at 22:07
  • As I said, I am a beginner, so I do not know how to get a stack trace. Could you share a link that can help me with the subject? – Chandler De Angelis Dec 30 '12 at 22:10
  • http://stackoverflow.com/questions/1093999/stack-trace-or-more-info-on-unhandled-exception-in-xcode-iphone – CodaFi Dec 30 '12 at 22:12
  • @ChandlerDeAngelis You need to put `NSLog` statements, or breakpoints, in those two functions to be sure they're getting called. If they don't get called when you click the buttons, you need to figure out why not. Perhaps the buttons aren't connected to them in your xib. – rob mayoff Dec 30 '12 at 22:46
  • In addition to breakpoints and log messages there are some other useful debugger instruments to catch errors. Try the code analyzer first. If analyzer will not find the problem, try Time Profiler. Select "Show objective-c only" and "Hide system libraries" to minimize the output and look what your application is doing if it is. – voromax Dec 30 '12 at 23:54
  • The problem is elsewhere. Maybe you managed to create an endless loop? Are you using ARC? Is it intended that you always push a new viewcontroller without poping another currently running before? – ott-- Dec 31 '12 at 19:15
  • I am using ARC. So you are saying I should pop the current view controller off the stack before I push the new one onto the stack? – Chandler De Angelis Dec 31 '12 at 21:49

2 Answers2

1

I'd suggest you check the connections between your IBActions and your code. Unexplained errors like this can be caused by missing or incorrect connections in IB.

Simon
  • 384
  • 4
  • 22
1

Seems like a memory problem.Instead of creating a p20viewcontroller object and tableviewcontroller object on every button click,try creating these objects only once somewhere in the start of the program.

the button click should only contain the code to navigate to the next screen.Not creating a new object on every button click.

zzzzz
  • 1,209
  • 2
  • 18
  • 45