title: Howto pass NSManagedObject via protocol/delegate?
body: <p>I have a managed object defined:</p>
  
  <pre><code>@objc (Game)
  class Game: NSManagedObject {
    @NSManaged var player1: Player
    @NSManaged var player2: Player
    @NSManaged var totalScore: NSNumber
    @NSManaged var gameDate: NSDate
  }
  </code></pre>
  
  <p>I initialize it from ViewControllerA, then I give it to ViewControllerB using the delegate pattern. The protocol looks like this:</p>
  
  <pre><code>protocol gameProtocol {
      func gameFunction(input: Game)
  }
  </code></pre>
  
  <p>ViewControllerB signs up for the protocol:</p>
  
  <pre><code>class ViewControllerB: UIViewController, gameProtocol {...}
  </code></pre>
  
  <p>and implements this function to conform:</p>
  
  <pre><code>func gameFunction(input: Game) {
      let currentGame = input
  }
  </code></pre>
  
  <p>Then ViewControllerA can send a Game object to VCB as follows:</p>
  
  <pre><code>var gameDelegate: gameProtocol!
  gameDelegate.gameFunction(myInitializedAndSavedGameObject)
  </code></pre>
  
  <p>This all works, but I need a class level variable inside ViewControllerB so that other code can be written to depend on the game. This, of course, does not work:</p>
  
  <pre><code>var currentGame = Game()
  func gameFunction(input: Game) {
      currentGame = input
  }
  </code></pre>
  
  <p>I don't know the right words for it, but I think I want an initialized, empty Game object. I suppose I could write a convenience init that makes a temporary Game, but that doesn't seem like a good idea.</p>
  
  <p>My current workaround is to have an NSManagedObjectID() and then recreate the object from the ID. But this is a lot of repeated code to get at an object that is central to what this ViewController is designed to work with. </p>