Saturday, 15 May 2010

iphone - removeobject from nsmutablearray -



iphone - removeobject from nsmutablearray -

i m doing quiz application in have stored correctanswer , question id in nsmutablearray.i m displaying in section tableview.now if mark reply in same section prevoius have removed , 1 has attached array. im unable .

nsmutablearray *cellsection = [self.finalarray objectatindex:indexpath.section]; int n=[cellsection count]; nsstring *questionid=[[cellsection objectatindex:n-1]objectforkey:@"qid"]; (nsdictionary *dict in selectedoptionandqidarray) { nsstring *str=[dict valueforkey:@"qid"]; [arr1 addobject:str]; } bool istheobjectthere = [arr1 containsobject:questionid]; if(istheobjectthere==yes) { //remove prevoius reply , replace new reply same question id } [selectedoptionsarray addobject:dictionary1]; nsdictionary *dictinary2 =[[nsdictionary alloc] initwithobjectsandkeys:questionid, @"qid", nil]; [selectedoptionsarray addobject:dictinary2]; [selectedoptionandqidarray addobject:selectedoptionsarray];

but istheobjectthere 'no' eventhough there same question id.

how can remove prevoius 1 , replace new 1

id object = [[array objectatindex:0] retain]; [array removeobjectatindex:0]; [array insertobject:object atindex:2];

use these lines.

iphone nsmutablearray xcode4.5

No comments:

Post a Comment