title: Execute function on startup
body: <p>I'm trying to develop an application for IOS using swift language that is a news for me. I want to fill a dictionary (tobaccoList) on the application startup. I have a csv file, so I take data from this file and than i fill the dictionary:</p>
  
  <pre><code>class DataManager{
  
  var latitudes = Array&lt;Double&gt;()
  var longitudes = Array&lt;Double&gt;()
  var tobaccoList = Dictionary&lt;Double, Tabacchino&gt;()
  
  init(){
  
      if let url = NSURL(fileURLWithPath: "/Users/brunopistone/Developer/apptabacchi/LocationList_sorted.csv" , isDirectory: true) {
          var error: NSErrorPointer = nil
          if let csv = CSV(contentsOfURL: url, error: error) {
  
              //put every tabbacchino in a Dictionary tobaccoList
              let rows = csv.rows
              let totalRows = rows.count
  
              for var index = 1; index &lt; totalRows; index++ {
                  let temp = csv.rows[index]
                  let tabacchino = Tabacchino(
                      name: temp["Name"]!, phone: temp["tnumber"]!, lat: NSString(string: temp["Latitude"]!).doubleValue, lon: NSString(string: temp["Longitude"]!).doubleValue
                  )
                  let keyGeo = NSString(string: temp["Latitude"]!).doubleValue
                  storeTobaccoShop(keyGeo, value: tabacchino)
  
                  var doubleLatitude = NSString(string: temp["Latitude"]!).doubleValue
                  var doubleLongitude = NSString(string: temp["Longitude"]!).doubleValue
                  storeLatitude(doubleLatitude)
                  storeLongitudes(doubleLongitude)
              }
          }
      }
  }
  
  func storeTobaccoShop(key: Double, value: Tabacchino) {
      self.tobaccoList[key] = value
  }
  </code></pre>
  
  <p>In the viewController file of the home page i have:</p>
  
  <pre><code>class ViewController: UIViewController, CLLocationManagerDelegate {
  
  let startFunction = DataManager()
  let locationManager = CLLocationManager()
  var latitude = Double()
  var longitude = Double()
  var tobaccoList = Dictionary&lt;Double, Tabacchino&gt;()
  
  override func viewDidLoad() {
  
      self.locationManager.delegate = self
      self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
      self.locationManager.requestWhenInUseAuthorization()
      locationManager.startUpdatingLocation()
  
      tobaccoList = startFunction.getTobaccoList()
  
  }
  </code></pre>
  
  <p>In the home page, I have a button that calls another view, and i want to pass the dictionary to the other view in order to use it, so I use this method:</p>
  
  <pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
      if segue.identifier == "tobaccoListSegue"{
  
          let viewList = segue.destinationViewController as! ViewList
          viewList.tabacchini = tobaccoList
      }
  }
  </code></pre>
  
  <p>The problem is, when i click on the button in order to call viewList, the application fills again the dictionary. What i want is to fill the dictionary only when I open the application.
  Please help me fix this thing. Thanks</p>