iphone - Fetch NSarray from the NSDictionary of NSArray using objectForKey -
i have nsarray
contain n number of nsdictionary
samplearray =
( { 0 = 0; 1 = 0; }, { 0 = 86400; 1 = 2; }, { 0 = 172800; 1 = 4; }, { 0 = 259200; 1 = 5; } )
now need fetch nsarray objectforkey
0 [samplearray objectforkey:[nsnumber numberwithint:0]]
, result nsarray should (0,86400,172800,259200) unable fetch result , app crashes.
normally nsdictionary, if key value set using nsstring
valueforkey
above operation performed if key value set using object nsnumber objectforkey
unable perform operation.
please me solution, suggestion appreciated!!
a straight forward way if keys nsnumber
objects:
nsmutablearray *result = [[nsmutablearray alloc] init]; (nsdictionary *d in a) { if (d[@0]) { [result addobject:d[@0]]; } }
Comments
Post a Comment