0

I have one NSDictionary and one NSMutableArray And I want store many object from NSDictionary into NSMutableArray from one key but I dont know about it.

this is my code :

//NSArray * a = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"7",@"9", nil];
//NSArray *b = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"0", nil];
NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys:a,@"number1",b,@"number2", nil];

NSMutableArray *array = [NSMutableArray alloc].... ?

I want store object in number1 key from NSDictionary in NSMutableArray

1
  • 1
    [array addObject:dic[@"number1"]];? Commented Jun 3, 2013 at 9:56

2 Answers 2

1

Since it appears that you store arrays as NSDictionary elements, you can do this:

NSMutableArray *array = [[NSMutableArray alloc] initiWithArray:dic[@"number1"]];

or

NSMutableArray *array = [NSMutableArray arrayWithArray:dic[@"number1"]];
Sign up to request clarification or add additional context in comments.

Comments

0

To add object into NsDictionary Array do:

NSMutableDictionary * datos = [array objectAtIndex:i];
[datos setObject:@"hola" objectForKey@"newKey"];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.