retain entries in UITableView

I have the following (view) controller arrangement:

an uitableview --(embedded in)--> navigation controller --(embedded in)--> Tab bar controller --(modal segue to)--> button in a view (uiviewcontroller).

description of my problem:

The view with the button is the initial view of my app. Pressing this button leads to a tableview in a tab bar. At the beginning the table view is empty, but you can manually add information on the cells, like names. However, once you go back to initial view (with button) and press the button again, the previous entries in the table view are erased.Can somebody give a hint how to retain these entries with the given arrangement. Thank you very much in advance.

Answers


You can use the singleton pattern. It will create a shared instance of your object, that you can access anywhere. You will then be able to write in it when the user adds a row in the table, and read it when you come to the tableView.

Here is a bit of help : Singleton pattern

EDIT : you can also use core data, but it may not be appropriate in your situation (plenty of docs on the web about that one)


This is quite a question as it really isn't about the interface per se. It is more to do with general Object Orientated Programming and the life time of objects.

Basically your data needs to be stored higher up the object hierarchy. It needs to persist across construction/destruction of the interface objects. This could also be done by storing the data in persist-able data store such as a DB or file but you would still need to store the means to extract the data or subset of data from the store.

If you wish to persist the data you could store data in a singleton data class and reference it statically or store it in your UIApplication object and pass that down the hierarchy as you create each object. you would probably have to subclass each object and add a new constructor passing in a ref to the data.


Need Your Help

Auto-save textarea every so many seconds

php ajax jquery

I need help with "auto-saving" a textarea. Basically, whenever a user is typing in the textarea, I would like to save a "draft" in our database. So for example, a user is typing a blog post. Every 15

which.min not working correctly inside sapply on data-frame?

r which sapply

Can anyone explain this strange behavior found when trying to use sapply and which.min to find the first lines inside a dataframe satisfying a condition?