0

I have some problem understanding how to read an array of x elements from an UITableView and pass it to the SQLite assigning a name to it. Like a TODO List assigned to people's name.

I have created the database, I can save (null) fields except for the name of the list, but now I do not know how can I read all the fields and pass to my SQLite. Any hint?

In PHP, I usually use a foreach, but I am new to Obj-C and I a little bit blocked.

UPDATE:

The "+" button add a new row, instead the "Save" button has to save this list to an sqlite database. But I am blocked on how to read and save all the fields.

save the table

2 Answers 2

2

A UITableView is a view and should not store your data. Usually you will have a ViewController that serves as the DataSource for the table view. This controller usually holds some array of sort that stores the data displayed in the table view.

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

2 Comments

Sorry my question was written not in a good way. I know that the UITableView does not save anything, but I want to pass those data to the SQLite. I think that the image could clarify my intention.
If you have access to the array than any available tutorial on SQLite should allow you to understand how to save that array to SQLite. The fact that you are also displaying the data in that array in a tableview should not alter that task.
1
  1. What is the data source of your tableView ? each tableView object ( witch inherits from UITableView) should have a datasource who gives it the data to display in it's view.

  2. You can use an SQLite wrapper so save/Load easily in/from an SQLite data base. FMDB

6 Comments

In the IB the dataSource and the delegate are the Table View (myTableView).
Here is the link to the project: dropbox.com/s/8fqwmhnrmjdusam/TodoList2%202.zip
you have an array of all your tasks : arrayofTasks, this array contain all the tasks witch are created and you have an other array :tasks
Ok, I am really sorry, but because I do not know how many tasks there are added in the list, do I have to create something like: while(the last line is not reached) {add to the arrayofTasks}?
self.tasks contains all the task currently displayed in your tableView, you can iterate like this : for (Task *task in sel.tasks) { ...}
|

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.