Obj-C, NSScanner: nil string argument, suddenly getting this warning, how do I fix it?

让人想犯罪 __ 提交于 2020-01-06 12:43:10

问题


I'm suddenly getting this warning NSScanner: nil string argument in the debug window.

I say suddenly, but I've no idea from which code has caused it.

How do I resolve this problem ?


回答1:


You check if the string is nil before creating the NSScanner with it, as you are probably creating it with

+ (id)scannerWithString:(NSString *)aString

or

- (id)initWithString:(NSString *)aString

There is no way of changing the NSScanner string, once it has been created, the compiler is just telling you that it is pointless to create a NSScanner with a nil string.




回答2:


I had solved this problem by removeObserver:forKeyPath: in dealloc where I had used KVO.



来源:https://stackoverflow.com/questions/8113139/obj-c-nsscanner-nil-string-argument-suddenly-getting-this-warning-how-do-i-f

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