Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get data from dictionary and add them into an array in ios

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 256
    Comment on it

    If you want to get data from dictionary and add them into an array below code will help you, In this blog firstly i have created a NSMutableAarray and after that created a NSArray which contain the value like ram,13 etc then i created a NSMutableDictionary which create a key for array after that i have added all the data from dictionary into a mainArray and display all the data.

                NSMutableArray *mainArray = [NSMutableArray array];
    
                NSArray *array1 = [NSArray arrayWithObjects:@"Ram",
                         [NSNumber numberWithInteger:13],
    
                         [NSArray arrayWithObjects:@"Kumar",@"Singal",nil],
    
                         nil];
    
    NSLog(@"The array contain the following element %@",array1);
    
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setObject:array1 forKey:@"data"];
    
    NSLog(@"the dictionary is %@",dict);
    
    [mainArray addObjectsFromArray:[dict objectForKey:@"data"]];
    
    NSLog(@"main array is %@",mainArray);
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: