iOS dev
iOS dev

Reputation: 1

how to sort data of a table View alphabetical in sections

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 section "A" I want all cell which start with alphabet "A".

Upvotes: 0

Views: 664

Answers (2)

maahi
maahi

Reputation: 11

 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];
        } 

Upvotes: 1

Praveen-K
Praveen-K

Reputation: 3401

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

}

Upvotes: 0

Related Questions