开发者

I want to use characterAtIndex:(NSUInteger)index method of NSString class

开发者 https://www.devze.com 2023-02-06 00:30 出处:网络
I want to compare the value returned by characterAtIndex:(NSUInteger)index of NSString class wit开发者_JAVA技巧h a another NSString having one character stored in it any suggestion On the top of my he

I want to compare the value returned by characterAtIndex:(NSUInteger)index of NSString class wit开发者_JAVA技巧h a another NSString having one character stored in it any suggestion


On the top of my head, you can compare them directly using characterAtIndex on the other NSString as well.

if([string characterAtIndex:index] == [stringWithOneChar characterAtIndex:0]){
   // Do something here...
}


NSString *temp = @"Hello";
NSString *temp2 = @"H";

if([temp characterAtIndex:0] == [temp2 characterAtIndex:0] )
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号