title: Adding objects to an array using Swift without duplication
body: <p>I am still getting familiar with Swift, and I am having troubles with adding objects to an array at this moment. 
  Also the array shouldn't have duplicates.</p>
  
  <p><strong>What I have so far -</strong> </p>
  
  <p>A function that is called when user does a button click on a prototype cell. 
  <strong>I am trying to achieve</strong> -</p>
  
  <ol>
  <li>Select button (and indicate with a checkmark that he selected/deselected the item)</li>
  <li>For each selected item, I have two values - bool status <code>isActive</code> and the selected item's <code>subscriptionID</code></li>
  <li>When user selects the item, I need to add this selection as an object and further append this to an array.</li>
  <li>For that, I have <code>subscriptionUpdateData: NSDictionary</code> and my new empty array <code>subscriptionsArray: [NSDictionary] = []</code> </li>
  </ol>
  
  <p><strong>Full Function</strong>   </p>
  
  <pre><code> func subscriptionCell(cell: SubscriptionCell, didToggleSubscription subscription: Subscriptions) {
  
          var subscriptionsArray: [NSDictionary] = []
          var subscriptionUpdateData: NSDictionary = ["subscriptionID": 0, "isActive": false]
  
          if let matchingSubscription = subscriptionInformation?.filter({ $0.subscriptionID == subscription.subscriptionID }).first {
  
              matchingSubscription.isActive = !(matchingSubscription.isActive!)
  
              let subscriptionStatus = matchingSubscription.isActive
              let subscriptionStatusForId = matchingSubscription.subscriptionID
  
              subscriptionUpdateData = ["subscriptionID": subscriptionStatusForId!, "isActive": subscriptionStatus!]
              tableView.reloadData()
          }
          subscriptionsArray.append(subscriptionUpdateData)
          print("\(subscriptionsArray)")
  
      }
  </code></pre>
  
  <p><strong>What is going on with above -</strong>
  I am able to select an item, form it as a dictionary, and add it to my array. :-) 
  But whenever I select a different item in my list of items, it replaces the existing element in the array with the newly selected item. :-(</p>
  
  <p>I am looking for something like below (without duplicates) which is an input to a REST endpoint -</p>
  
  <pre><code>    [{   "subscriptionID" : 1234, 
          "isActive" : true
      },
      {
          "subscriptionID" : 5678, 
          "isActive" : false
      },
      {
          "subscriptionID" : 3489, 
          "isActive" : true
      }]
  </code></pre>
  
  <p>Can someone look into where I am missing something? Or whether there is a better way I can do this?</p>