objective c - NSMutableArray check if item exists -


i've got 1 nsmutablearray 100+ characters in i've populated table with:

int rowcount = indexpath.row; character *character = [self.characterarray objectatindex:rowcount];  cell.textlabel.text = character.name; cell.detailtextlabel.text = character._id; 

i've got separate nsmutablearray _id , neighbour values in, array has around 8 values random id's in.

basically want check if character._id exists in second array, it'll display checkmark on table.

i've tried doing:

neighbour *neighbour = [self.neighbourarray objectatindex:rowcount];  if (character._id == neighbour._id && neighbour.neighbour == 1){          cell.accessorytype = uitableviewcellaccessorycheckmark;     }else{          cell.accessorytype = none; } 

but crashes app (because has 8 values of 100, i'm guessing)

is there easy way around or better way check altogether?

thanks, constructive advise appreciated, i'm brand new xcode.

you can use kvc avoid enumeration:

bool result = [[neighbours valueforkey:@"_id"] containsobject: character._id]; 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -