title: How to get line number, method name, and class name when crash occurs using Objective C
body: <p>I am developing an app in which I have to track crashes. There is a restriction that I can't use any third party source like Twitter's Fabric framework to handle crash logging.</p>
  
  <p>Currently I am only able to get the reason for crash. I am not able to get the exact point of crash.</p>
  
  <p>What I am doing:</p>
  
  <p>In my app delegate's <code>didFinishLaunchingWithOptions</code> method I had made my own exception handler:</p>
  
  <pre><code>    NSSetUncaughtExceptionHandler(&amp;uncaughtExceptionHandler); 
  </code></pre>
  
  <p>uncaughtExceptionHandler ----</p>
  
  <pre><code>void uncaughtExceptionHandler(NSException *exception) {
      NSLog(@"CRASH: %@", exception);
      NSLog(@"callStackSymbols: %@", [exception callStackSymbols]);
      NSLog(@"callStackReturnAddresses: %@", [exception callStackReturnAddresses]);
      NSLog(@"reason: %@", [exception reason]);
      NSLog(@"name: %@", [exception name]);    
      NSLog(@"%s %d %s %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, __FUNCTION__);
  // Internal error reporting
  }
  </code></pre>
  
  <p>I crashed my app in <code>viewDidLoad</code> method using this:</p>
  
  <pre><code>   NSArray *myary;
  
     myary = [NSArray arrayWithObjects:@"sad", nil];
  
     NSString *str =  [myary objectAtIndex:22];
  </code></pre>
  
  <p><a href="http://pastebin.com/hBvgcn1H" rel="nofollow noreferrer">Here is my Stack Trace</a>.</p>
  
  <p>Is their any way to achieve what I want?</p>
  
  <p>I tried following these solutions from SO but they don't give me any lead:</p>
  
  <p><a href="https://stackoverflow.com/questions/27960178/how-to-get-class-method-and-line-number-of-uncaught-exception-using-nssetuncau">Solution 1</a></p>
  
  <p><a href="https://stackoverflow.com/questions/12141804/how-to-get-source-code-line-from-stack-trace-in-obj-c-ios">Solution 2</a></p>