0

I had two NSDictionary elements in the finalOrderArray before addingObject. Then I added sharedData.comboItems but this object is also an array of NSDictionary.

Now,I have a mix of NSDictionary and NSArray which is difficult to handle.

Is there an easy way to add NSDictionary all together?

[finalOrderArray addObject:sharedData.comboItems];

enter image description here

Desired output in this example, finalOrderArray would have 6 dictionaries rather than having 2 dictionaries and one array of dictionary.

3 Answers 3

3

Use addObjectsFromArray: method.

Adds the objects contained in another given array to the end of the receiving array’s content.

Here is the link to NSMutableArray and all its methods.

Sign up to request clarification or add additional context in comments.

Comments

1

Use addObjectsFromArray method. It will add all the objects from sharedData.comboItems. Try this.

[finalOrderArray addObjectsFromArray: sharedData.comboItems];

Comments

0

sharedData.comboItems is an array that's why you get one array in your finalOrderArray. You need to iterate through the array, get the dictionary and add to finalOrderArray.

Like this:

for (NSDictionary *item in sharedData.comboItems) {
   [finalOrderArray addObject:item];
}

1 Comment

Is there a short way to handling this issue without looping it?

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.