Obj-C,NSScanner:nil 字符串参数,突然收到此警告,我该如何解决?
问题描述:
我突然在调试窗口中收到此警告 NSScanner: nil string argument
.
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 ?
答
在使用它创建 NSScanner 之前检查字符串是否为 nil,因为您可能使用
You check if the string is nil before creating the NSScanner with it, as you are probably creating it with
+ (id)scannerWithString:(NSString *)aString
或
- (id)initWithString:(NSString *)aString
没有办法改变 NSScanner 字符串,一旦它被创建,编译器只是告诉你用 nil 字符串创建一个 NSScanner 是没有意义的.
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.