How do I print only the values and not the keys?

Discussion in 'iOS Programming' started by Alhazred, Jul 5, 2011.

  1. Alhazred macrumors member

    Joined:
    Jul 5, 2011
    #1
    I'm creating a simple app which asks to the user to put a text inside a text field, this text is sent to a php script on an application server, the script performs a search on a database and send the result back to tha app formatted as JSON

    With this code I print the response into the console
    Code:
    NSString *response = [[[NSString alloc] initWithData:dati encoding:NSASCIIStringEncoding] autorelease];
    NSMutableArray *jsonarray = [response JSONValue];
    for (int i=0; i<[jsonarray count]; i++) {
    	NSLog(@"jsonarray: %@", [jsonarray objectAtIndex:i]);
    }
    
    Data in the console appear like this
    Code:
    2011-07-05 09:45:51.632 RecuperoInfo[20391:207] jsonarray: {
        img = "barca.jpg";
        testo = "Una barca";
    }
    2011-07-05 09:45:51.637 RecuperoInfo[20391:207] jsonarray: {
        img = "form.jpg";
        testo = "Immagine di una form";
    }
    2011-07-05 09:45:51.646 RecuperoInfo[20391:207] jsonarray: {
        img = "bmw.jpg";
        testo = "Una BMW";
    }
    
    How do I print only the values and not the keys?

    In example I want to print this:
    barca.jpg - Una barca
    form.jpg - Immagine di una form
    bmw.jpg - una BMW
     
  2. Alhazred thread starter macrumors member

    Joined:
    Jul 5, 2011
  3. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #4
    ^ ^ ^ Definitely this.

    valueForKey: is part of the Key-Value Coding infrastructure. It's working, but it's not what you actually want.
     
  4. Alhazred thread starter macrumors member

    Joined:
    Jul 5, 2011

Share This Page