ios - how to check a mutable string contains a string value or not in iphone? -


i have beeen storing string values mutablearray store in nsuserdefaults.like way `

nsmutablearray *arrayobj = [nsmutablearray arraywitharray:[[nsuserdefaults standarduserdefaults] objectforkey:@"emoved"]];       for(int = 0 ; i<[searcharray count]; i++)      {          nslog(@"%@",searcharray);          nsdictionary *dictionarydate = [searcharray objectatindex:i];          nsstring *memeid=[[dictionarydate objectforkey:@"id"]description];           if([dictionarydate objectforkey:@"dateofinfo"])         {             if ([arrayobj containsobject:memeid])             {                            }             else             {                 [arrayobj addobject:memeid];             }         }         }     [[nsuserdefaults standarduserdefaults] setobject:arrayobj forkey:@"emoved"]; 

` when printng need add value @ once .but when priting value seing same value added array multiple times.is there wrong in approach can point out?

you should allocate , initialize nsmutablearray like

nsmutablearray *arrayobj = [[nsmutablearray alloc] initwitharray:[[nsuserdefaults standarduserdefaults] objectforkey:@"emoved"]]; 

if aren't using arc, don't forget release arrayobj right after you're done it


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -