title: Different Realm Configurations Appearing in Swift App
body: <p><em>Swift 3, Xcode 8, RealmSwift 2.0.2, Realm Object Server 1.0</em></p>
  
  <p>In my app delegate, I have a function that sets my Realm configuration to connect to a remote sync server I have set up. I'm just using a test account to authenticate until I can get the basics of sync working. <code>1.1.1.1</code> isn't my real IP address. ;)</p>
  
  <pre><code>let username = "test"
  let password = "test"
  
  let address = "http://1.1.1.1:9080"
  let syncAddress = "realm://1.1.1.1:9080/~/myapp"
  
  SyncUser.authenticate(with: Credential.usernamePassword(username: username, password: password, actions: []), server: URL(string: address)!, onCompletion: { user, error in
      guard let user = user else {
        fatalError(String(describing: error))
      }
  
      // Open Realm
      Realm.Configuration.defaultConfiguration = Realm.Configuration(
        syncConfiguration: (user, URL(string: syncAddress)!)
      )
   })
  </code></pre>
  
  <p>This seems to work fine. I see data appear on my server, and I get no errors. <strong>My assumption is that setting the Realm configuration here means that all instances of <code>Realm()</code> will use this configuration.</strong></p>
  
  <p>I then set a <code>realm</code> object as a class property in two separate view controllers:</p>
  
  <pre><code>class TableViewControllerA: UITableViewController{
    let realm = try! Realm()
    override func viewDidLoad() {
      // CORRECT: Prints "nil" as it should for a remotely synced Realm instance
      print(realm.configuration.fileURL)
    }
  }
  </code></pre>
  
  <p>...and another in another file:</p>
  
  <pre><code>class ViewControllerB: UIViewController{
    let realm = try! Realm()
    override func viewDidLoad() {
      // WRONG: Prints the path to the local realm file in the Simulator
      print(realm.configuration.fileURL) 
    }
  }
  </code></pre>
  
  <p>As noted in the code comments above, the two instances of <code>realm</code> are different. On some of my view controllers, I can save objects to the server and see them appear on my device. On other view controllers, I don't see any data because it's using the wrong Realm database. </p>
  
  <p>Can I not reliably expect a Realm configuration to persist throughout my app? Do I need to do something else to use the same configuration?</p>