title: How to use existing SQLite database in swift?
body: <p>I know there are some resources available for this but none of them clearly show the way how to do it properly. </p>
  
  <p>I have already populated .sqlite database (MTrader.db) and i want to connect it to my swift project and load the data from the database into spinner. </p>
  
  <p>I tried so many ways but it doesn't work. I try to edit 
  <strong>lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator?</strong>  method in AppDelegete.swift as </p>
  
  <pre><code>if !NSFileManager.defaultManager().fileExistsAtPath(url.path!) {
              let sourceSqliteURLs = [NSBundle.mainBundle().URLForResource("MTrader", withExtension: "db")!]
  
              let destSqliteURLs = [self.applicationDocumentsDirectory.URLByAppendingPathComponent("MTrader.db")]
  
              var error:NSError? = nil
              for var index = 0; index &lt; sourceSqliteURLs.count; index++ {
                  NSFileManager.defaultManager().copyItemAtURL(sourceSqliteURLs[index], toURL: destSqliteURLs[index], error: &amp;error)
              }
          }
  </code></pre>
  
  <p>For some reason above code isn't working. I copied my database file in my project. So is there any error with my code or any better way to use my existing database without creating new database and populating it?</p>