title: Swift: NSCountedSet with Map
body: <p>I would prefer to use <code>Person</code> <code>Struct</code>, but I since it does not confirm to <code>AnyObject</code>, I can't use it with <code>NSCountedSet</code></p>
  
  <pre><code>class Person: AnyObject {
      var name: String = ""
      var age: Int = 0
      var score: Int = 0
  }
  
  
  let personA = Person()
  personA.name = "john"
  let personB = Person()
  personB.name = "larry"
  let personC = Person()
  personC.name = "jack"
  let personD = Person()
  personD.name = "bob"
  
  
  var people:[AnyObject] = [personD, personC, personA, personB, personC, personA, personC, personD, personD]
  let countedPeople = NSCountedSet(array: people)  //
  </code></pre>
  
  <p>I would like to assign the "score" property in each object to the count of each object from <code>NSCountedSet</code></p>
  
  <p>I am trying to do this with <code>Map</code>.  Code below does not compile.</p>
  
  <pre><code>let peopleWithUpdatedScore = countedPeople.map{( var person: Person) -&gt; Person  in
       // I would like to assign the count of each Object as the persons score. 
      person.score = countForObject(person) 
      return person
  }
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>error: cannot convert value of type 'Person -&gt; Person' to expected argument type '(Element) -&gt; _'
  let peopleWithUpdatedScore = countedPeople.map{( var person: Person) -&gt; Person  in
  </code></pre>
  
  <p>Question1: How can resolve the error and achieve what I am trying to do?</p>
  
  <p>Question2: Can I use a <code>Struct</code> instead of the a <code>Person</code>'s <code>class</code>?</p>