How can I find the location of a specific character in an NSString?
I have tried this but it returns an empty range (I want to find the location of the '?'):
NSRange range = [@"This is a ? test to see if it works" rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInStrin开发者_如何学运维g:@"?"]];
maybe this will work?
NSString* s = @"hello?";
NSRange range = [s rangeOfString:@"?"];
You must doing something else wrong. Because this is absolutely correct and returns {10, 1}
. At least on my mac it does ;-)
精彩评论