Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Combining Arrays

Hi When I parse my data I create 5-6 mutable arrays. Each array has the same number of objects [20] and each object has 2 properties [month and sales data]. The month properties are always the same for each array with only the sales data changing. The data comes from different sources which is why I create multiple arrays.

Once I have formed the arrays is there a way to create a combined array which would have objects with properties 'month' 'sales data A', 'sales data B', 'sales data C' etc etc.

Or is there a way once I have formed the first array that I can add a property to the existing objects to form the combined array that way.

I'm new to development so I see my question being answered in one of the two ways, if not both.

Thanks

2 Answers

Hi Stephen.... Just wanted to check... have you created a new separate class to store all the data... If I were at your place i would have created a separate class and stored all the arrays there and used them as properties...

Hi Rashu, thanks for responding. I'm new to object orientated programming but I'm trying! I have created custom classes for the objects in each array [I form the arrays in viewDidLoad and manipulate them there]. Each of the custom objects has 2 properties [month and data]. I'd like to combine them so that the objects have properties of month, data1, data2, data3 etc. I don't think I can do this when I form them as I parse some HTML data and the sales data is in different areas. I hope that makes sense.

well, what you could do is, that may be you could apply an if statement like: if (month==month1) { print month,data1,data2, data3 etc }

I hope this helps.... You can paste the code here... so it will give more visibility ....