二、ChineseString.h
#import
#import "pinyin.h"
@interface ChineseString : NSObject
@property(strong,nonatomic)NSString *string;
@property(strong,nonatomic)NSString *pinYin;
//----- 返回tableview右方indexArray
+(NSMutableArray*)IndexArray:(NSArray*)stringArr;
//----- 返回联系人
+(NSMutableArray*)LetterSortArray:(NSArray*)stringArr;
///----------------------
//返回一组字母排序数组(中英混排)
+(NSMutableArray*)SortArray:(NSArray*)stringArr;
@end
三、ChineseString.cpp
#import "ChineseString.h"
@implementation ChineseString
@synthesize string;
@synthesize pinYin;
#pragma mark - 返回tableview右方 indexArray
+(NSMutableArray*)IndexArray:(NSArray*)stringArr
{
NSMutableArray *tempArray = [self ReturnSortChineseArrar:stringArr];
NSMutableArray *A_Result = [NSMutableArray array];
NSString *tempString ;
for (NSString* object in tempArray)
{
NSString *pinyin = [((ChineseString*)object).pinYin substringToIndex:1];
//不同
if(![tempString isEqualToString:pinyin])
{
// NSLog(@"IndexArray----->%@",pinyin);
[A_Result addObject:pinyin];
tempString = pinyin;
}
}
return A_Result;
}
#pragma mark - 返回联系人
+(NSMutableArray*)LetterSortArray:(NSArray*)strin