iphone - Filtering an NSDictionary within a dictionary with particular text -
i getting web service repsonse array of dictionary. each dictionary has objects values dictionary.i need implement search within response,like if enter "technology" , go search, should dictionary array has "technology anywhere within dictionary", there solution sort out
{ key1 = { 0 = { "id" = 608; "b" = "apple-iphone"; }; 1 = { "id" = 609; "b" = "iphone"; }; 2 = { "id" = 610; "b" = "show text"; }; }; key2 = "technology resources"; "key3" = { 0 = { "id" = 1608; "b" = "i love reading"; }; 1 = { "id" = 1609; "b" = "i prefer iphone others"; }; 2 = { "id" = 1610; "b" = "mobile technology great.i happy developer"; }; }; "key4" = "mobile technology fun"; }
this first method
nsmutabledictionary *dict; nsarray *allkeys = [dict allkeys]; (nsstring *key in allkeys) { nsdictionary *innerdict = [dict objectforkey:key]; nsarray *allinnerkeys = [innerdict allkeys]; (nsstring *innerkey in allinnerkeys) { nsdictionary *mostinnerdict = [dict objectforkey:innerkey]; nsstring *b = [mostinnerdict objectforkey:b]; nsstring *search = @"technology"; nsstring *sub = [b substringfromindex:nsmaxrange([b rangeofstring:search])]; if(sub) { // add mostinnerdict object results array } } }
or can try simpler method
get response in nsdata
covert nsdata nsstring
and search in nsstring substring
Comments
Post a Comment