I'm using Gamekit to send data via bluetooth between two devices. I want to get the name of the device that sent it, but if the name is "Bob's iPhone" I want to cut off the "'s iPhone". I first check for ending in "iPhone" or "iPod Touch".
if ([name hasSuffix:@" iPhone"])
{
name = [name substringToIndex:[name length]-7];
}
else if ([name hasSuffix:@" iPod Touch"])
{
name = [name substringToIndex:[name length]-11];
}
But when I do the same for "'s" it never returns true. Also the apostrophe looks slightly different then the default apostrophe.
if ([name hasSuffix:@"'s"])
{
name = [name substringToIndex:[name length]-2];
}
Is there some trick to detecting apostrophes? Is there a way I can do this?
EDIT: The apostrophe on the left is what name contains, but is not registering with hasSuffix:@"'s". The apostrophe on the right is the apostrophe I added.
It might be the case of encoded string. You should make sure the string about this cases
is it 's
or is it ´s
or is it ‘s
or some other character.
You may have some other character that is causing you problems.
These are my guess. Hoping this helps you to find out your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With