title: File Scope? Swift Delegates and Protocols
body: <p>I'm working on building a new Swift app roughly based off an old Obj-c app. I'm currently working on the delegates</p>
  
  <p>Here is what my obj-c code looked like in the .h file</p>
  
  <pre><code>@interface MyAppViewController : CustomViewController
  @property (nonatomic, weak) id&lt;MyAppViewControllerDelegate&gt; delegate;
  @end
  
  @protocol MyAppViewControllerDelegate &lt;NSObject&gt;
  - (void)myAppViewController:(MyAppViewController *)controller loggedInStudent:    (MYStudent *)student;
  - (void)myAppViewControllerWantsSignUp:(MyAppViewController *)controller;
  @end
  </code></pre>
  
  <p>In SWIFT I did:</p>
  
  <pre><code>class MyAppViewController: CustomViewController {
  
  var delegate: MyAppViewControllerDelegate?
  protocol MyAppViewControllerDelegate{
  func myAppViewController(controller: MyAppViewController, loggedInStudent:     MYStudent)
  func myAppViewControllerWantsSignUp(controller: MyAppViewController)
  </code></pre>
  
  <p>I've done a lot of reading and study on this, so I thought I was doing it basically right (totally new to swift though... so) </p>
  
  <p>I'm getting this error though, "<code>Declaration is only valid in file scope</code>" on the <code>protocol MyAppViewControllerDelegate {</code>
  I assumed this had something to do with declaring it within the class, so I moved it out, only now my code within the class doesn't recognize the delegate variable I declared.. </p>
  
  <p>Any ideas?</p>