title: How to pass an NSDictionary to a function and return another NSDictionary in Swift 2
body: <p>I'm trying to pass <code>businesses</code> (an NSDictionary) to a function that iterates through it and returns a selected business (also an NSDictionary) back to the view controller. I'm having trouble setting up the proper call and completion handler in Swift. I don't think I'm handling the input of the businesses dictionary properly in my function.</p>
  
  <p>With the code below, I'm getting an error that I have an extra argument in the call. Do I need to wrap the call in a do/try/catch? I'm new to Swift and was a bit confused about the different ways to use completion handlers and pass items to a function. Most of the questions on stack overflow that I've found relate to how to use NSURLSession and haven't been as helpful. Happy to be pointed in the direction of documentation or a relevant blog post if that's easier. Thanks.</p>
  
  <p>ViewConteroller, where I call the function and pass the businesses dictionary:</p>
  
  <pre><code>FindBar.searchForOpenBar(businesses) {(selectedBar) -&gt; Void in     
      print(selectedBar)
  }
  </code></pre>
  
  <p>From FindBar where the logic (not implemented yet) that selects which bar to return to be used by the view controller.</p>
  
  <pre><code>class FindBar {
      typealias Completion = (selectedBar:NSDictionary) -&gt; Void
      func searchForOpenBar(businesses: NSDictionary, completion: Completion) {
  
          //iterate through the businesses and select the bar
          for business in businesses {
  
              //temp. hard-coded selection
              foundBar = ["name":"Dive Bar", "address":"123 Main St"]
  
          }
  
      //send selected bar back view controller.
      completion(selectedBar: foundBar)
  
  }
  </code></pre>