IOS中字符串操作
1.比较大小
- (NSComparisonResult)compare:(NSString *)string;
返回值NSComparisonResult有3种情况:
NSOrderedAscending = -1L, // 升序(左边 < 右边)
NSOrderedSame, // 内容相等(左边 == 右边)
NSOrderedDescending // 降序(左边 > 右边)
比如[@"ab" compare:@"ad"]返回NSOrderedAscending
比如[@"ab" compare:@"aa"]返回NSOrderedDescending
比如[@"ab" compare:@"ab"]返回NSOrderedSame
2.获得某个位置的字符
- (unichar)characterAtIndex:(NSUInteger)index;