Reputation: 8473
I'm just doing a plain old string comparison for an if condition and I got a weird behavior. In the console, I got the following and fell off my seat.
(lldb) po [@"Puc X-1234" rangeOfString:@"Puc"]
nil
How can this be?
Upvotes: 0
Views: 68
Reputation: 46608
rangeOfString:
return NSRange
, which is not an object but po
is for print objc object
try p (NSRange)[@"Puc X-1234" rangeOfString:@"Puc"]
the reason it print nil
is that the returning NSRange
is (0,3)
, then the debugger take the 0
part and assume it is id
type, and print nil
Upvotes: 6