2011-01-19 38 views

回答

4
NSString類的索引

在我頭上,你可以直接使用另一個NSString上的characterAtIndex來比較它們。

if([string characterAtIndex:index] == [stringWithOneChar characterAtIndex:0]){ 
    // Do something here... 
} 
2
NSString *temp = @"Hello"; 
NSString *temp2 = @"H"; 

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