title: How to transfer button sender to another class
body: <p>So I am building a simple messenger in swift. I am using a view state enum for different UIs upon <code>viewWillAppear</code> i.e .Offline, .Default. I have a <code>convoVC</code> and an <code>InboxVC</code></p>
  
  <p>From my <code>InboxVC</code>, I am transitioning to a <code>convoVC</code> which displays messages between the user and another user that is either selected from the inbox (in which case I want .Default state for <code>conversationVC</code>), or selected from a query using a searchbar when I transition from a "compose new message" button (in which case I want ".Compose" state for <code>conversationVC</code>). </p>
  
  <p>I am having trouble setting the state on <code>convoVC</code> given the sender of my function which calls the segue from <code>InboxVC</code> to <code>convoVC</code> </p>
  
  <blockquote>
    <p>sender of type UIBarbuttonItem if the compose button is pressed to make the transition, or sender of type myAppName.InboxVC if tableview cell is pressed to make the transition.</p>
  </blockquote>
  
  <p>Code for what happens in each state is trivial, for lack of a better word. </p>
  
  <p>This is my action function in <code>InboxVC</code> called from either my tableView's <code>didSelectRowAtIndexPath method</code>, or from <code>barButtonItem</code> selector:</p>
  
  <pre><code>func compose(sender: AnyObject) {
      self.performSegueWithIdentifier("toConversation", sender: sender)
  }
  </code></pre>
  
  <p>I have tried capturing sender (within compose function, and within <code>ViewWillDisappear</code> but not both) in a variable declared within <code>InboxVC</code> and transferring it to another variable in <code>convoVC</code> to then check its type to set state in <code>convoVC</code>.</p>
  
  <p>My problem is that it always comes out to nil. How do I transfer the sender? pls help I am new to swift.
  Thanks! (tagged obj-c because translating is not hard)</p>
  
  <p>the variable is called sender in both VCs and is declared as type AnyObject?</p>
  
  <p>I tried</p>
  
  <pre><code>self.sender = sender
  convoVC().sender = sender
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code>self.sender = sender
  </code></pre>
  
  <p>and then setting <code>sender (in convoVC) = InboxVC().sender</code></p>