# Multiplying interface elements?

**URL:** <https://forums.kodeco.com/t/multiplying-interface-elements/26290>\
**Category:** Swift\
**Created:** [February 16, 2017, 2:49pm UTC](https://forums.kodeco.com/t/multiplying-interface-elements/26290 "2017-02-16T14:49:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpepermans](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bpepermans/32/57732_2.png) [@bpepermans](https://forums.kodeco.com/u/bpepermans)\
**Post date:** [February 16, 2017, 2:49pm UTC](https://forums.kodeco.com/t/multiplying-interface-elements/26290/1 "2017-02-16T14:49:13Z")

</div>

Hello there,

First post, first question… Currently developing my first “big app”, I’m looking for the (best) way to duplicate elements and their usage.

Here’s the two situations where I need it to happen…

1. Multiple players

My app asks for name, a number, a color for X players. Depending on X I have to duplicate rows and then get access to the variables like “name\_1”, “name\_2”, and so on.  
For now, I’m managing two players by duplicating fields in the storyboard and hiding the one I don’t need. It works but it’s not clean and will become a problem with 5 players…

How do I create / duplicate lines programmatically and maintain access to the data ?

1. Multiple scores  
After the game is created, I will ask the user to enter data on several categories for each player.

I have a column with 7 different textfields for each players where the user will enter corresponding values.  
Same question as above but maybe same answer ?

Thanks a lot for any help !

Ben

---

<div class="post-metadata">

**Author:** ![rcasey](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/rcasey/32/82229_2.png) [@rcasey](https://forums.kodeco.com/u/rcasey)\
**Post date:** [February 16, 2017, 6:20pm UTC](https://forums.kodeco.com/t/multiplying-interface-elements/26290/2 "2017-02-16T18:20:21Z")

</div>

Check out UICollectionView or UITableView.

You can define a custom cell with all of your interface elements for a single player, and then set your collection/table size to the desired number of players. Store all your player info in an array and use that array to feed the cells in your collection/table.

We’ve got a bunch of tutorials on this site that can help you get started. [Here is one](https://www.raywenderlich.com/136159/uicollectionview-tutorial-getting-started) for UICollectionView.

Have fun!

---

<div class="post-metadata">

**Author:** ![bpepermans](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bpepermans/32/57732_2.png) [@bpepermans](https://forums.kodeco.com/u/bpepermans)\
**Post date:** [February 16, 2017, 10:45pm UTC](https://forums.kodeco.com/t/multiplying-interface-elements/26290/3 "2017-02-16T22:45:01Z")

</div>

Thanks for The reply, I begin ton undrestand the idea.

But is it possible for the players’ scores, that the UICollection cells contain a single column table view ?

Most important how do I link actions to the inner elements (fields, buttons, etc) that are specific to each player (ie altering his score) ?

Thx
