What causes "NSScanner: nil string argument"?
Asked Answered
V

5

29

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.

Vitrescence answered 17/8, 2011 at 15:14 Comment(2)
put some brake points and some logs on all your date to see what object is nilCragsman
THX. I found I save a textfiled's value which I had deleted in IB.Vitrescence
O
38

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.

Oakes answered 1/9, 2011 at 3:17 Comment(3)
Jep, I had the problem, trying to create an NSDecimalNumber with a nil string will log this warning.Musteline
If your usage of NSLog is sparse, you can also break on NSLog, which is used to produce the error message.Skillless
@GuillaumeAlgis look for a up vote on some answer you gave previously from me! Your comment on NSLog just saved my hours of work!!!Nedanedda
S
5

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.

Skerl answered 1/9, 2011 at 8:6 Comment(0)
E
0

I have the same crash log NSScanner: nil string argument.

This is my sitution

  • Everything works fine on device.
  • Crash at dequeueReusableCellWithIdentifier only on simulator

I solved it by

Product->Clean Then rebuild.Every thing works fine for me. I not sure why this happened.

Ethyne answered 31/7, 2015 at 6:59 Comment(0)
V
0

I had met this problem on iOS 9 and iOS 10 BUT iOS 11 work fine,I solved it by removing observer in dealloc where I had used KVO.

Such as:

- (void)dealloc {
[self.collectionView removeObserver:self forKeyPath:@"contentSize"];
}
Vestigial answered 9/5, 2018 at 7:47 Comment(0)
I
-2

I got this crash error but not about nil string issue. My reason is that I use a cell in storyboard as dynamic but set Static Cells in the Attributes inspector. I changed that attribute to Dynamic Prototypes, solved the problem.

Involve answered 16/10, 2014 at 8:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.