Reputation: 9376
I have a product
string:
NSString* product = models[[[peripheral identifier] UUIDString]];
and in the debugger I can print:
po product
>>> X3
and I can check the bytes:
po [product dataUsingEncoding:NSUTF8StringEncoding]
>>> <5833>
I can also check the bytes of the literal string @"X3"
:
po [@"X3" dataUsingEncoding:NSUTF8StringEncoding]
>>> <5833>
And I get the same output. However, when I try to do:
[product isEqualToString:@"X3"]
>>> <nil>
I get nil
. What the heck!? I can understand when there is a hidden character or something, but when the bytes evaluate to the same thing, then I'm baffled.
I can even do:
NSData *d = [product dataUsingEncoding:NSUTF8StringEncoding];
NSData *d2 = [@"X3" dataUsingEncoding:NSUTF8StringEncoding];
po [d isEqualToData:d2]
>>> YES
Upvotes: 0
Views: 65