Learn Courses My Dashboard

Bundle of arrays

I’m trying to bundle and present information from a Firebase DB in a table view.
I would like to show only the latest date according to different kind of categories in the tableView.
(see below). Unfortunately I couldn’t find a proper solution in google. Is there an easy way to bundle such kind of information in an array? I would be happy to get some hints. Thanks a lot !

e.g.:
Content DB:
[message 1; date; category A; text, …]
[message 2; date*; category A; text, …]
[message 3; date; category B; text, …]
[message 4; date*; category B; text, …]
[message 5; date*; category C; text, …]

  • latest date

Should show in TableView:
[message 2; date*; category A; text, …]
[message 4; date*; category B; text, …]
[message 5; date*; category C; text, …]

Welcome to the community!

These dates with the star, are they all the exact same date?

You can filter your array that’s returned from Firebase and check for a specific date and only use those rows in your table view

Happy to be here :blush:

There are different kind of dates. I just wanted to take the latest one for each category.
I tried to sort the dates first and put the data in a new array with a loop method, but that’s maybe not the best solution, especially if the database is quite big.