0
 #import "ViewController.h"

    @interface ViewController ()

    //Declare block as property

    @property (nonatomic, strong) void (^dataBlock)(BOOL success);

    @end

    @implementation ViewController

    - (void) myMethod1:(void (^)(BOOL success))response {

        //Here data block holds the reference to response block

        _dataBlock = response;    
    }

    - (void) myMethod2 {

        //Check for _dataBlock and invoke it.

        if (_dataBlock) {    
            _dataBlock(YES);   
        }    
    }

   - (IBAction) buttonClick {

     //Call for myMethod1 and call back block is invoked in myMethod2

        [self myMethod1:^(BOOL success) { 

            if (success) {   
                NSLog(@"Im Done");   
            }    

        }];
   }
   @end

Above sample is my code in Objective-C

  • Callback Block of "myMethod1"(response) is having reference/stored to "dataBlock" Property.
  • then invoke "dataBlock" from "myMethod2".
  • since "datablock" have reference to"myMethod1" block named "response", i'll be getting call back in "myMethod1", please look at the code snippet (similar to function to pointer).
  • same thing i want to implement in swift. I have tried implementing this in swift using closures, but not getting it.
0

2 Answers 2

2

No, there is not, unless it's on a Jailbroken device.

Apple does not let 3rd party apps alter the core behavior of the phone.

Now you could put the phone in a Faraday cage and put antennas on the inside and outside, and disconnect them when you wanted to block calls.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for response.
1

Actually you sort of can, but not really programmatically from iOS. If the BLE device implements the HID profile then you can simulate a double click on the lock button which would dismiss the call. I have done that, but it is a bit of a clunky solution.

2 Comments

Thanks, Can you share a solution, if possible.
Have a look at usb.org/developers/hidpage/Hut1_12v2.pdf Consumer Page (0x0C), Usage ID 0x30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.