[iOS]一行代码给中文数组添加索引

/**
 *  将原数据以及存放索引的空数组 传参  返回整理后的数组
 *  已用分类封装,直接引入头文件 使用方法即可
 *
 * https://github.com/KKKKaras/JY_SectionDemo
 */


#import "JYTableViewController.h"
#import "ChineseString.h"
#import "NSObject+Index.h"
@interface JYTableViewController ()
{
    NSMutableArray * _listArray; //源数据
    NSMutableArray *_AbcSort;   //排序整理后的数组
    NSMutableArray *_sectionHeadsKeys;//存放索引的数组
    
    
}
@end

@implementation JYTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _AbcSort=[[NSMutableArray alloc]init];
     _sectionHeadsKeys=[[NSMutableArray alloc]init];
    _listArray = [[NSMutableArray alloc]initWithObjects:@"白居易",@"柳惊涛",@"莫雨",@"王遗风",@"唐大侠",@"李白",@"杜甫",nil];
    
    //获取数据
    _AbcSort = [ self getChineseStringArr : _listArray andSck:_sectionHeadsKeys ];
    
 
}

https://github.com/KKKKaras/JY_SectionDemo


猜你喜欢

转载自blog.csdn.net/w250130255/article/details/44590831
今日推荐