What causes “NSScanner: nil string argument”?

你。 提交于 2019-12-03 22:11:07
Jeremy W. Sherman

From experience, I can say that -[NSDecimalNumber initWithString:] 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:. That's how I flushed my unwanted log statement out.

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.

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.

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"];
}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!