NSDictionary access problem

Discussion in 'iOS Programming' started by vikasA, Mar 7, 2011.

  1. vikasA macrumors newbie

    Joined:
    Mar 7, 2011
    #1
    I want to access the value for each key in this dictionary

    { "key1": "val1", "key2" : "val2", "key3" : "val3", "key4" : [{ "key41": "val41", "key42" : "value42" } ,{ "key41": "val41", "key42" : "value42" } ]}

    //for val1
    NSString *str = [[self.data objectForKey:Key1] objectAtIndex:1];

    //for val41
    NSString *str = [[[self.data objectForKey:Key4] objectForKey:1] objectAtIndex:row];


    But the app is crashing.

    any suggestion??
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Post all of the code, specifically the creation of the dictionary, all variable declarations, header declarations etc. Also post the exact error message printed to the console.
     
  3. huskerchad macrumors regular

    Joined:
    Jul 17, 2002
    #3
    Key4 looks like it should be giving you back an array, so you shouldn't be sending it objectForKey: messages, but objectAtIndex: messages instead.
     

Share This Page