title: New to Swift and confused - Store large constant/dataset in Swift class
body: <p>I'm building a little utility to load a CSV file into my app and read the next value about 5 times per second (The csv file is from a sensor logger)</p>
  
  <p>For this i'm using this csv library: <a href="https://github.com/naoty/SwiftCSV" rel="nofollow">https://github.com/naoty/SwiftCSV</a></p>
  
  <p>Now, the performance/update rate suffers dramatically with csv files with more than a few lines. The problem is that i can't for the life of it figure out how to NOT load the csv file with each time i call SensorRecording.getDatapoints()</p>
  
  <p>I'm guessing it should be a global class variable only loaded once, but adding the respective lines for the variables "csvURL" and "csv" at the top of the class declaration yields a strange </p>
  
  <blockquote>
    <p>"SensorRecording.Type does not have a member named 'csvPath'</p>
  </blockquote>
  
  <p>How could i store it in a global variable for that class? </p>
  
  <p>Here's the SensorRecording class code:</p>
  
  <pre><code>import UIKit
  
  class SensorRecording: UIViewController {
  
      var cur: Int = 1
  
      let csvPath = NSBundle.mainBundle().pathForResource("2014-09-21_23-25-32", ofType: "csv")
      let csvURL = NSURL.fileURLWithPath(csvPath!)
      let csv = CSV(contentsOfURL: csvURL!)
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view.
      }
  
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  
  
      func getDatapoints() -&gt; NSDictionary {
  
  
  
          let rows = csv.rows
  
          if (cur == (csv.rows.count-1)) { cur = 1 } else { cur++ }
  
          return csv.rows[cur]
  
      }
  </code></pre>
  
  <p>Many thanks</p>