Search code examples
iosuitableviewhidearchivesections

How to create an archive of UITableView entries?


I am working on a project that involves a table list and would like to have the following characteristics:

1) When I do leading swipe to an existing table entry an Archive button to appear next to the others buttons (copy and delete).

2) When I select the archive button then the entry would disappear from the current list and be moved to an archive section. At a later stage I would like to hide the Archive but I will do this later!

The UITableView is fully operational right now and I have added the copy and delete actions to the leading swipe of each table entry. But I am thinking what is the better way to managed the archive action. After reading and searching on the web and this great forum, it seems that I have two options on managing the data structure:

1) Add a new section and name it Archive. Make a new Array for the archived items. So it will be a questions of deleting from one Array and insert it into the other.

OR

2) Make a new struc that will include both current list and archived list and then have this new struc as the entry in the UITableView.

Since I am new to swift programming, I feel more confident understanding option (1) but then the code gets too messing with lots of mistakes.

Does anyone have any experience with what is the best data structures for moving around UITableView entries in various sections? Obviously if there is a better way of actually hiding entries and make re-appear even better. Any input would be most appreciated!

Thank you,

DeeNove750


Solution

  • For those curious enough, I decided to post my own answer. After lots of research and reading, seems like the best way to handle hiding/archiving UITableView entries is by redesign the data structure of my application. I made another class which basically is an Array of two: archived_items and non_archived_items. Then I use all the UITableViewController to move items around and manipulate data (insert, delete, move, hide/unhide and copy).

    Seems like the general process works, but still have some bugs I need to sort out.

    Brgds,

    DeeNove750