Search code examples
iosnsarraynsmutabledictionary

How to store values at key =0 into nsarray?


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


Solution

  • 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"]];
        }