objective c - Filtering Mutable Array using NSPredicate -


i have mutablearray 6 sub arrays , many subarrays within each subarrayclick here screenshot each array contains details of station......(there 146 arrays
altogether)

my goal filter array "name", @ same time want extract remaining details too. i'm trying using predicate method failing.

my searchresults array should having filtered arrays details of station on bases of "name". can me in achieving this? in advance.

-(void)filtercontentforsearchtext:(nsstring *)searchtext{   nspredicate *resultpredicate = [nspredicate predicatewithformat:@"any name contains[cd] %@",searchtext]; _searchresults = [ _stationsarray filteredarrayusingpredicate:resultpredicate];  }   - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nullable nsstring *)searchstring{  [self filtercontentforsearchtext:searchstring]; return yes; } 

can try this!!!

    #import <foundation/foundation.h>      @interface stationdetail : nsobject          @property (nonatomic, strong) nsstring *name;      @end      - (void)viewdidload {         [super viewdidload];         // additional setup after loading view, typically nib.          // initialize          stationsarray = [[nsmutablearray alloc] init];          nsarray *stationname = [[nsarray alloc] initwithobjects: @"chennai", @"bangalore", @"kochi", @"mumbai", @"delhi", @"hyderbad", @"pune", @"agra", @"jaipur", nil];          int index = 0;         (int = 0; < 3; i++) {             nsmutablearray *substationsarray = [[nsmutablearray alloc] init];              (int j = 0; j < 3; j++) {                  stationdetail *station = [[stationdetail alloc] init];                  [station setname:[stationname objectatindex:index]];                  [substationsarray addobject:station];                  index++;               }             [stationsarray addobject:substationsarray];         }       }       -(void)filtercontentforsearchtext:(nsstring *)searchtext{         // 1 parameter of object need filtered         nspredicate *resultpredicate = [nspredicate predicatewithformat:@"name contains[cd] %@",searchtext]; // name object key name          nsarray *searchresults = [ stationsarray filteredarrayusingpredicate:resultpredicate];         nslog(@"%lu",(unsigned long)[searchresults count]);      }      -(void)searchbarsearchbuttonclicked:(uisearchbar *)searchbar{         [self filtercontentforsearchtext:searchbar.text];     } 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo