Ali
Ali

Reputation: 11550

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

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

Answers (2)

Mihir Mehta
Mihir Mehta

Reputation: 13833

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

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

Upvotes: 2

Gianz
Gianz

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

Related Questions