0

I have an iOS tabbed application with three tabs. The first view controller calculates your one rep max bench press. When you press the calculate button to calculate the results, it also populates a table on the second view controller. Within the table it displays the 60%, 65%, 70%, 75%, 80%, 85%, 90%, and 95% of the one rep total.

What I cannot figure out is how to add text to each line of the table saying "60% of your one rep max is:" and then populate the data from the array.

Is there a way to statically add text to a table, and then populate it with data from an array?

I have attached a picture of the table:

image

1

1 Answer 1

1

You can learn how to achieve this from this video: https://www.youtube.com/watch?v=N8h8FH3c7TU

The main ideas are:

  1. Your view needs to extend UITableViewDataSource and UITableViewDelegate and

    tableView.delegate = self tableView.dataSource = self

  2. You should set how many rows are in tableView through

    func numberOfRowsInTableView(_ tableView: NSTableView) -> Int

  3. You should set how many section are:

    func numberOfSectionsInTableView(_ tableView: UITableView) -> Int

  4. You should say what type of cell you want to display and init it with data from your array:

    func tableView(_ tableView: UITableView,cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

And when you want to reload data just reload the array that use for create tableViewCell and call tableView.reloadData()

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

1 Comment

Thanks to everyone who took the time to answer. Appreciated.

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.