title: Pull data from SQL Server via SQLClient in Swift
body: <p>I am trying to pull data from SQL Server and I can't store data. I am getting all rows but "outside" the function my data is zero. It means before I disconnect from DB I have data, but when I close connection all data disappeared.</p>
  
  <p>I am thinking this is because I have shallow copies and I need deep copying</p>
  
  <pre><code>import Foundation
  import SQLClient
  
  class RecipeViewModel{
  var recipes = [Recipe]()
  
  init(){
      getRecipeFromDB()
  }
  
  func getRecipeFromDB(){
  
      let client = SQLClient.sharedInstance() as! SQLClient
  
      client.connect("x.x.x.x", username: "xx", password: "xxx", database: "xxx") {
          success in
          client.execute("SELECT item FROM TABLE") {
              results in
  
              for table in results as! [[[String:AnyObject]]] {
                  for row in table {
  
                      for (columnName, value) in row {
                          let recipe = Recipe(code: value as! String, title: "Title")
                          recipes.append(recipe)
                          }
                      }
                  }
  // prints all recipes. Everything is perfect
  
          for i in self.recipes{
              print(i.code)
          }
              client.disconnect()
          }
  //prints nothing. recipe.count = 0
  
          for i in self.recipes{
              print(i.code)
          }
      }
  }
  
  func error(error: String!, code: Int32, severity: Int32) {
      print(error)
      }
  }
  </code></pre>