title: Realm EXC_BAD_ACCESS when querying database
body: <p>Im new to realm. I have read the documentation and followed the examples in creating and querying the database. Whenever I run the code below it crashes on the line  </p>
  
  <blockquote>
    <p>let realm = Realm</p>
  </blockquote>
  
  <p>I have a view controller that I am trying to query realm like so:</p>
  
  <pre><code>            // Get the default Realm
              let realm = Realm()
              // Query using an NSPredicate
              let predicate = NSPredicate(format: "s3_url = %@", s3_url)
              let medias =  realm.objects(MediaRealm).filter(predicate)
  </code></pre>
  
  <p>everytime i run this i get Thread1: EXC_BAD_ACCESS</p>
  
  <blockquote>
    <p>let realm = Realm()</p>
  </blockquote>
  
  <pre><code>import UIKit
  import Alamofire
  import RealmSwift
  
  class ViewController: UIViewController {
  
      let mediaCollection = MediaCollection()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          loadInitialData()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      func loadInitialData(){
          //connect to url
          mediaCollection.fetch(onSuccess:{ self.onEventFetched($0) }, onError:{ self.displayAlert($0)})
      }
  
      func onEventFetched()-&gt;Void{
          println("Got stuff")
          println(mediaCollection.models.count)
          processCollection()
      }
  
      func processCollection()-&gt;Void{
  
          for media in mediaCollection.models{
              let m = media as! Media
              println(m.s3_url)
              println(m.title)
              if let s3_url = m.s3_url{
  
                  //query database, if it already exists dont download it
                  // Get the default Realm
                  let realm = Realm()
                  // Query using an NSPredicate
                  let predicate = NSPredicate(format: "s3_url = %@", s3_url)
                  let medias =  realm.objects(MediaRealm).filter(predicate)
                  if medias.count == 0 {
                      println("no files found")
                      //downloadFile(s3_url)
                  }
              }
          }
      }
  </code></pre>
  
  <p>What am I doing wrong?</p>