Error NSError *; vs NSError * error = nil;

I developed an ios application that has:

NSError *error; 

instead:

NSError *error = nil;  

It worked great when I debugged the simulator and debugged it when connected. The moment I archived it and sent it to TestFlight for deployment for testing, I started getting errors An unknown signal in the crash log.

Why is this happening?

+5
source share
2 answers

This is because you have an uninitialized pointer. This doesn't crash while you're lucky, but using such pointers is undefined behavior .

+7
source

To clarify dasblinkenlights answer, this declares a variable:

NSError *error; 

...

NSError *error = nil;  

, , , , "". , . , , , .

+3

All Articles