1

I want to store all the emails into an array. What do I need to do for the same ?

Gurp321
  • 109
  • 2
  • 11
  • response{ 0 = { email = "grover@gmail.com"; firstname = Grover; }; 1 = { email = "hems@gmail.com"; firstname = Gems; }; 2 = { email = "rohit@gmail.com"; firstname = Rohit; }; } – Gurp321 Jul 19 '16 at 07:09
  • In the same question, I want to get the email and first name of index 2. How can I do that ? – Gurp321 Jul 19 '16 at 09:05
  • NSString * email = [[repsonseDict objectForKey:@"yourIndex"]objectForKey:@"email"]] //set "firstname" for name – Pranav Jul 19 '16 at 09:14

1 Answers1

0

Use this code and change it according to your requirement

    NSMutableDictionery * repsonseDict = [[NSMutableDictionery alloc]init];
    repsonseDict =  [reponseObj objectForKey@"response"];

    NSArray * allKeys = [repsonseDict allKeys];

    NSMutableArray * emailArr = [[NSMutableArray alloc]init];

    for(int i = 0; i < [allKeys count]; i ++ ){

      NSString * numberKey = [NSString stringWithFormat:@"%d",i];

     [emailArr addObject:[[repsonseDict objectForKey:numberKey]objectForKey:@"email"]];
    }
Pranav
  • 701
  • 4
  • 18