title: How Can I Create a Dynamic Grid of UIView Elements from Swift Array?
body: <p>I would like to create a basic grid made with UIView elements on an XCode storyboard by iterating over an array of items in a Swift ViewController.</p>
  
  <p>I am learning Swift.  My background is in JavaScript so the way I'd approach this problem in the world of the DOM Web browser would be to write something like this (ES5 example):</p>
  
  <pre><code>&lt;div id="my-div-wrapper"&gt;&lt;/div&gt;
  
  var myDivWrapper = document.querySelector('#my-div-wrapper');
  var myArray = [1,2,3,4,5,6,7,8];
  
  for (var i = 0; i &lt; myArray.length; i++) {
      var grid_block_id = myArray[i];
  
      myDivWrapper.insertAdjacentHTML('beforeend', '&lt;div class="grid-block-div"&gt;'+grid_block_id+'&lt;/div&gt;');
  }
  </code></pre>
  
  <p>Any suggestions on how this can be replicated in swift?</p>