title: How to count occurrences of an element in a Swift array?
body: <p>I've seen a few examples of this but all of those seem to rely on knowing which element you want to count the occurrences of. My array is generated dynamically so I have no way of knowing which element I want to count the occurrences of (I want to count the occurrences of all of them). Can anyone advise?</p>
  
  <p>Thanks in advance</p>
  
  <p>EDIT:</p>
  
  <p>Perhaps I should have been clearer, the array will contain multiple different strings (e.g. 
  <code>["FOO", "FOO", "BAR", "FOOBAR"]</code></p>
  
  <p>How can I count the occurrences of foo, bar and foobar without knowing what they are in advance?</p>