Using a .plist to populate a tableView

Hi,

I am in the process of making an app that will get the data from a plist.


The example that I used to make the tableView https://www.ioscreator.com/tutorials/load-data-property-list-ios-tutorialcontained one row. The app that I am doing would contain two rows, for example:


Name of resource phone number


Now I have two questions:


1. Is the property list the best way to do this?

2. Is there a better way to do a tableView, so I can easily update the list when it's necessary.


The way I am thinking about doing it now is the following:


if (indexPath.row == 0)

{

cell.detailTextLabel.text = "555-555-5555")

}


I am open to any suggestions.


Thanks,

Dan

Accepted Reply

In a database, which is what you are talking about, at least conceptually, "rows" are all identical. What you are talking about is adding a new "column". Each column is unique.


A table view just displays a grid (organized in rows and colums) from an array. Where you get the array data from or what you do with the array data is a separate issue. You can definitely use a plist to start with.


In a table view, you normally don't do that kind of specific row checking for data. You just dump the data in an array and the table displays it all.

Replies

> Is the property list the best way to do this?


About your data...how much/how may records; will it be editable by the user; will it be updated by you later, if so, how; what type of security will be involved.

In a database, which is what you are talking about, at least conceptually, "rows" are all identical. What you are talking about is adding a new "column". Each column is unique.


A table view just displays a grid (organized in rows and colums) from an array. Where you get the array data from or what you do with the array data is a separate issue. You can definitely use a plist to start with.


In a table view, you normally don't do that kind of specific row checking for data. You just dump the data in an array and the table displays it all.

Updating the table view when necessary has nothing or little to do with the way you store data:

- all changes occur in the datastore, usually an array where you keep that you load from permanent storage (plist or other as a file)

- TableView just reloads data from this datastore in its delegate func.