Question

Basics: iOS Application developed using XCode (latest version), Objective-C/C++ modules

I have a problem that may require some expert help.... My application is designed to run on the iOS platform, on all hardware, but I'm hitting a wall. The application runs fine on all of the simulators, on my iPod and iPad, but some of my testers have iPhones, and the problem only shows up on that hardware platform.

The basic problem is that the application seems to abend at various points, sometimes early in use, sometimes after more than an hour. I suspect it might be a memory leak or an invalid call that only occasionally rears its ugly head, but I need to find out. I've already coded the application to create a log file when it runs in "debug" builds, and I can deploy those to my testers who have iPhones, but I cannot always get access to their phones to retrieve the log files.

I have a mechanism built into the application to send emails of screen captures, and I can easily modify that to send the log files to me, but I need a way to trigger that.

My question: I come from a MS-based world, and I know how to trap an exception from inside my application there, including adding memory probes that automatically report on problems and call the appropriate methods before the application actually exits. Is there a way, from inside the application itself, to trap these problems and report on them automatically before the application ends and all useable information is lost?

Also, if there is some way to walk/dump the call stack programmatically, writing it to my log file, in the same manner that the simulators provide when using a simulator in XCode, and save that information as well, it would be of great help.

Thanks.

p.s.: I know this isn't a simple request, and that the response will also most probably not be simple, so thanks in advance for your help.

Was it helpful?

Solution

I have used this code for global level exception handling. I was suffering from a problem that any point of running app produce exception and app got crash, so I have implement application level exception handling.

Please refer this link on stack overflow may be this is useful for you.

How do you implement global iPhone Exception Handling?

Write this NSSetUncaughtExceptionHandler (&uncaughtExceptionHandler) line of code in applicationDidFixnishLaunchin Method of Appdelegate Class

    -(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:  
      (NSDictionary*)launchOptions
     {   
         NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); 

       EDIT:
         if( [[NSUserDefaults standardUserDefaults] boolForKey:@"isExceptionOccured"])
         {
        //call sever code here
       [[NSUserDefaults standardUserDefaults] setBool:FALSE forKey:@"isExceptionOccured"];
       }
       //rest of your code
      }


       void uncaughtExceptionHandler(NSException *exception)
      {


       NSLog(@"Exception Got %@",[exception description]);
        //do what ever you what here 
     //can save any `bool` so that as aaplication  run on immediate next launching of crash
     //could intimate any thing

    EDIT: 

    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"isExceptionOccured"];

      }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top