title: Call class method with argument from another class method
body: <p>In my code file <strong>MyItemVC.swift</strong> I have defined the following class and method:</p>
  
  <pre><code>class MyItemVC: UIViewController, UITextViewDelegate {
  
  var timer = NSTimer()
  
      func cycleTimer(toggleOn: Bool) {
          if toggleOn == true {
              // Timer calls the replaceItem method every 3 seconds
              timer = NSTimer.scheduledTimerWithTimeInterval(3, target: self, selector: Selector("replaceItem"), userInfo: nil, repeats: true)
          } else {
              timer.invalidate() // stop the timer
          }
      }
  }
  </code></pre>
  
  <p>Elsewhere in this class, I call cycleTimer(true) to start the timer and cycleTimer(false) to stop it.</p>
  
  <p>Now, I also want to use the usual methods in my <strong>AppDelegate.swift</strong> code file to start and stop the timer when the app moves from active to inactive state. But I'm having trouble calling the cycleTimer method from that class.</p>
  
  <p>I found an answer on Stack Overflow that suggested I could call it like this:</p>
  
  <pre><code>func applicationWillResignActive(application: UIApplication) {
  
      MyItemVC.cycleTimer()
  }
  </code></pre>
  
  <p>But I also need to pass in an argument. So I tried calling it like this:</p>
  
  <pre><code>func applicationWillResignActive(application: UIApplication) {
  
      MyItemVC.cycleTimer(true)
  }
  </code></pre>
  
  <p>But I got this error:</p>
  
  <blockquote>
    <p>Cannot invoke 'cycleTimer' with an argument list of type '(Bool)'</p>
  </blockquote>
  
  <p>How can I call this method from the AppDelegate methods while passing in an argument? </p>
  
  <p>Thanks for the help. I realize this must be a very basic question but I'm new to programming and trying to teach myself using Swift. An answer using Swift rather than Obj-C would be greatly appreciated.</p>