title: Disconnect or connect an iPhone call programmatically
body: <p>I'm working on a personal tweak for iOS. I want to disconnect/connect a phone call before the phone would show anything. I'm hooking into the <code>initWithAlertController:</code> method of class <code>SBUIFullscreenAlertAdapter</code>. Everything is okay when I just show a message that shows the incoming phone number and its name, but when i try to answer the phone call or disconnect it programmatically, it will crash and go to safe mode.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>@interface SBUIFullscreenAlertAdapter
  - (id)initWithAlertController:(id)arg1;
  @end
  
  @interface MPIncomingPhoneCallController
  {
      struct __CTCall *_incomingCall;
  }
  - (id) incomingCallNumber;
  - (void)stopRingingOrVibrating;
  - (void)answerCall:(struct __CTCall *)arg1;
  @end
  
  %hook SBUIFullscreenAlertAdapter
  - (id)initWithAlertController:(id)arg1
  {
      MPIncomingPhoneCallController *phoneCall = (MPIncomingPhoneCallController*)arg1;
      [phoneCall stopRingingOrVibrating];
      if([phoneCall.incomingCallNumber isEqualToString:@"+98.........."]) {
          [phoneCall answerCall:_incomingCall];
      }
      %orig;
      return self;
  }
  %end
  </code></pre>
  
  <p>The error is that it says: "Use of undeclared identifier '_incomingCall'".</p>
  
  <p>How can I solve the problem? Is there a way to use a private instance variable while hooking a method? Is there a function which returns a <code>CTCallRef*</code> of the incoming call? Is there some other way to accomplish this?</p>
  
  <p>It should be obvious that I'm coding for jailbroken iOS devices, so there is no problem with the use of private frameworks.</p>