Domanda

I am new to XCode and Objective C. I have intentionally make a mistake to assign number to NSString*.

NSString* s = @1;
[s uppercaseString];

Though XCode gives me warning, this code will compile. But at runtime I get exception. Now I see in logs, (Sorry for image, I was not able to paste is as text properly due to formatting)

enter image description here

In this log, how I find exact place of error. How this log tells me which code to change.

È stato utile?

Soluzione 2

To understand what line causes the problem, you usually need to add exception breakpoint to your project as explained in this document;

  1. In the bottom-left corner of the breakpoints navigator, click the Add button.
  2. Choose Add Exception Breakpoint.
  3. In the Exception pop-up menu, choose the type of exception on which you want execution to stop:
    • All. Stops on all exceptions.
    • Objective-C. Stops on Objective-C exceptions.
    • C++. Stops on C++ exceptions. To stop on a particular C++ exception, specify the exception name.
  4. Choose the phase of the exception handling process at which you want program execution to stop.
  5. Click Done.

Altri suggerimenti

So it looks like you are running the Release build (debug symbols stripped) and if you got that crash log in a production environment you would need to symbolicate it in order to find the line.

This Apple TN gives some details of Symbolication.

In a development environment you would simply add an exception breakpoint and run it from Xcode, as the debug symbols would not be stripped.

line 5 Sam : [BIDViewController viewDidLoad] + 143 , if this is a release build , you need to resolve with symbols the memory address of the function , this is called "symbolize" the crash dump...

In the log look for your project name and you will come to know.

e.g.

line 5 Sam : [BIDViewController viewDidLoad] + 143 

If you want to produce real crash without warning, try following code it will produce index out of bound exception and will crash

NSArray *array = @[@"1",@"2"];
NSLog(@"Item not accessible->%@",(NSString*)array[2]);

set Exception breaking point or enable NSZombie object

enter image description here

or

NSZombie

From the menu bar, choose Project > Scheme > Edit Scheme

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top