title: How to pass array by reference without function ? swift
body: <p>I have this class:</p>
  
  <pre><code>class MainView:UIView{
  
      var categories:[Category]!
  
  }
  </code></pre>
  
  <p>i want to set the categories arg, but i need to pass it by reference not value. because it's more efficient and better.</p>
  
  <p>so if i did this:</p>
  
  <pre><code>let mainView  = MainView()
  mainView.categories = categoriesData.
  </code></pre>
  
  <p>then it pass it by value.</p>
  
  <p>if i need to pass it by reference i could do that by using function inside the MainView()</p>
  
  <pre><code>class MainView:UIView{
  
      var categories:[Category]!
      fun setCategories(inout categories: Int){
              self.categories = categories;
  
      }
  
  }
  </code></pre>
  
  <p>but if i don't want to use set function, How could i pass it by reference.
  e.g</p>
  
  <p><code>mainView.categories = &amp;categoriesData.</code> but that doesn't work ?thanks</p>