Reputation: 11550
I want to compare the value returned by characterAtIndex:(NSUInteger)index of NSString class with a another NSString having one character stored in it any suggestion
Upvotes: 0
Views: 1401
Reputation: 13833
NSString *temp = @"Hello";
NSString *temp2 = @"H";
if([temp characterAtIndex:0] == [temp2 characterAtIndex:0] )
Upvotes: 2
Reputation: 495
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...
}
Upvotes: 4