ios - How to skip a specific string when populating my UITableView -


i populating tableview data received server. data list of user activities within given timeframe. 1 such activity "login". not wish populate tableview string i'm not sure how skip when populating tableview.

here how populate cell

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {        static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];     @try{          nsmanagedobject *object = [self.fetchedresultscontroller objectatindexpath:indexpath];         nsstring *action = [object valueforkey:@"theactionname"];          if ([action isequaltostring:@"login"]) {              return cell;         }          return cell;      }@catch (nsexception *ex) {         uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];     return cell;     } } 

as can see tried using return cell know gives me blank cell when table displayed. i'm sure there simple line of code came blank search terms used. please enlighten me! thanks!

p.s. may thinking not putting in of cells pulled out bunch of code keep short.

update: heads on "isequaltostring:" worked fine "isequal" changed given received many suggestions so. not asking.

to more clear if had array containing terms: view, view, login, view. when tableview populated have 4 cells said; view, view, login, view. want ignore term login have 3 cells said view. thanks!

there can many way this.

i belive uitabelview should display datasource (here datasource self.fetchedresultscontroller) contains.

what can create nsarray self.fetchedresultscontroller not contain object.

try this:

nsmutablearray *newsource = [[nsmutablearray alloc] init];          for(int = 0; < self.fetchedresultscontroller.count ; i++)         {             nsmanagedobject *object = [self.fetchedresultscontroller objectatindexpath:indexpath];             nsstring *action = [object valueforkey:@"theactionname"];              if (![action isequal:@"login"])             {                 [newsource addobject:action];             }         }          [tableview reloaddata]; 

now use newsource instead of self.fetchedresultscontroller

you might think using 1 more array not good. believe it far easier using same array condition. don't have worry condition when perform operation uitableview remove object using indexpath.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -