Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 1.42 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Accessing values of unknown Dictionary Keys
  2. {
  3.     "themes": [
  4.         [
  5.             "Direction des Routes Secteur de Pithiviers ",
  6.             "mairies",
  7.             "Morailles 45300 PITHIVIERS LE VIEIL ",
  8.             "0238345744",
  9.             "48.823042",
  10.             "2.365907"
  11.         ],
  12.         [
  13.             "Crédit Mutuel Du Centre ",
  14.             "banques",
  15.             "agence de Pithiviers  33 r Am Gourdon 45300 PITHIVIERS",
  16.             "0820834080",
  17.             "48.703042",
  18.             "2.145907"
  19.         ]
  20.     ]
  21. }
  22.        
  23. NSDictionary *allThemesDict=[[request responseString]JSONValue];
  24.  NSArray *allThemesValues=[allThemesDict objectForKey:@"themes"];
  25.     for (int i=0; i<[allThemesValues count]; i++) {
  26.         NSDictionary *currentTheme=[allThemesValues objectAtIndex:i];//here i get the first 6 values, how can i display it?
  27.         }
  28.        
  29. NSDictionary *allThemesDict = [[request responseString] JSONValue];
  30. NSArray *allThemesValues = [allThemesDict objectForKey:@"themes"];
  31. for (int i=0; i<[allThemesValues count]; i++) {
  32.     NSArray *currentTheme = [allThemesValues objectAtIndex:i];
  33.     NSLog(@"currentTheme = %@", currentTheme);
  34.  
  35.     // Then access [currentTheme objectAtIndex:1] for example to get "mairies" in the first case.
  36. }
  37.        
  38. for (id key in myDictionary) {
  39.     //...
  40. }
  41.        
  42. NSDictionary *currentTheme=[allThemesValues objectAtIndex:i];
  43.         for (id item in currentTheme) {
  44.             NSLog(@"item: %@", item);
  45.         }
  46.     }