Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes "NSScanner: nil string argument"?

I got this message when I save data to core data.

NSScanner: nil string argument 

I didn't use any NSScanner method. Where did it come from?

This is a bug? What should I do with it?

Thanks help, please.

like image 665
Jimi Avatar asked Aug 17 '11 15:08

Jimi


2 Answers

From experience, I can say that -[NSDecimalNumber initWithString:] or +[NSDecimalNumber decimalNumberWithString:] with a nil string is one thing that causes that log message.

Set a breakpoint on -[NSScanner initWithString:] to start with; if you don't catch it that way, then break on the other ways you might create a scanner, like +scannerWithString: and -[NSConcreteScanner initWithString:]. That's how I flushed my unwanted log statement out.

like image 76
Jeremy W. Sherman Avatar answered Oct 02 '22 23:10

Jeremy W. Sherman


FWIW, I had this message come out whilst building a core data app.

It was due to me rebuilding and running the app in the simulator, which effectively kills off your running process without going through any of your exit methods.

Depending on when / where you are saving your managed object context, you could be left with an incomplete managed object somewhere, then scanners which would expect to find values would have nothing when the app was relaunched and the half baked objects were returned from the store.

like image 21
jrturton Avatar answered Oct 02 '22 23:10

jrturton