title: Dynamic or Generic Type Array in Swift
body: <p>I am stuck between <code>Array</code> type. What I want to do is to detect <code>Array</code> type runtime while entering values.</p>
  
  <p>I have one custom class defining <code>UIPickerView</code> and I want to pass the <code>datasource</code> based on requirements that sometimes the values may be <code>String</code>, <code>Int</code> or <code>Double</code>. So definitely, I can't define like below because typecasting will be issue.</p>
  
  <pre><code>var arrFirstComponent = [Any]()
  </code></pre>
  
  <p>So I want a solution like when I pass <code>Int</code> value the <code>Array</code> type becomes <code>Int</code> and when I pass <code>String</code> it becomes <code>String</code> type array or anything. </p>
  
  <p>Can anyone help me out in that? I have seriously no idea how to achieve it. </p>
  
  <p>P.S. I have seen many answers which inherit protocols but I din't find worthy. </p>