0

I made my project in storyboard in, due to issue with the custom UITableViewCell I have made a new project, copied all of the data to my new classes and copied my buttons, images etc from the storyboard views to new project's nib/xib files.

Now When I click on any button my app crashes without any error and it opens delegate file and highlights this line of code

return UIApplicationMain(argc, argv, nil, NSStringFromClass([ThisOrThatAppDelegate class]));

I have already made connections for the required actions from IB to controller. Also I have tried Command+Shift+K for clean code. But the problem is still there.

Omer Waqas Khan
  • 2,423
  • 4
  • 33
  • 62

1 Answers1

2

You have to find out first what the problem is:

  • use the Debug build config and are using lldb or gdb
  • make sure you have a breakpoint on all exceptions
  • make sure you have the "Breakpoints" button top left enabled.
  • run the app

You should break into the debugger. You need to get to a point where the debugger catches the exception.

Then edit your question and tell us what exception you get. I'm going to guess you'll be getting a objc_msgSend() error, which means that some object is trying to message a non-existent or dealloced object. If that turns out to be true, then you can enable "Zombies" (which lets all objects stay around) and see if one of those gets messaged.

If nothing seems to help, then what you need to do is start adding NSLog messages to track your app as it comes up (or use breakpoints, your choice). This takes a long time so you might work backwards - see if your appDelegate application:didFinishLaunchingWithOptions: gets called, and also if you get to the end of it.

Unforunately this type of problem can be take a lot of time to track down. Some object has probably queued a message up for another object on the main queue, so when you get the crash you don't get to see who did what when.

Also, with objc_msgSend problems, when the debugger stops you cannot easily see what object was messaged - but if you turn off the debugger and let the app actually crash, you can find the crash report in the Console app and get more info from that.

David H
  • 40,852
  • 12
  • 92
  • 138