开发者

how to sort data of a table View alphabetical in sections

开发者 https://www.devze.com 2023-03-25 06:07 出处:网络
I have created a tableview with 27 sections that are all alphabets, now what I need to do, I want to filter my data according to the sections, that means in secti开发者_开发百科on \"A\" I want all cel

I have created a tableview with 27 sections that are all alphabets, now what I need to do, I want to filter my data according to the sections, that means in secti开发者_开发百科on "A" I want all cell which start with alphabet "A".


 for(int i=0;i<[list count];i++){

        NSString *newString;
        NSString *mystring;

        newString=[list1 objectAtIndex:i];
        if( ( [newString characterAtIndex:0] == 'a' )||[newString characterAtIndex:0] == 'A' ){
            //  mystring = [newString substringFromIndex:0];
            mystring=newString;
            //[self.giftlist1 addObjectsFromArray:giftlist];
            [self.listA addObject:mystring];
        } 


for (id alphabet in allSecionArray) {
    if ([searchString hasPrefix:alphabet]) {
        NSLog(@"Result  is %@", searchString); // which you can add your result in your      NSmutuable resultArray
    }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号