title: Detect phone calls on iOS with CTCallCenter (Swift)
body: <p>I wanted to try to detect incoming phone calls in my app. I created a new Swift project from scratch just to try some code. The only thing I did was importing CoreTelephony in the ViewController that is created with every new project and I also changed the viewDidLoad() to:</p>
  
  <pre><code>    super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  
      let callCenter = CTCallCenter()
      NSLog("start")
  
      callCenter.callEventHandler = {[weak self] (call: CTCall) -&gt; () in
  
          self?.label.text = call.callState
          NSLog("Call state")
          NSLog(call.callState)
  
      }
  </code></pre>
  
  <p>I also tried without the [weak self] since I am new to swift and not sure of what it entails.</p>
  
  <p>When I run my new little app via XCode on my phone nothing happens when a call is received, disconnected or anything else. No error what so ever. Do I have to do something more in order to use the CoreTelephony framework and the CTCallCenter?</p>
  
  <p>Regards
  Johan</p>