I try to catch all touch events all over the world. To do this, I know that I can connect touch event procedures in the UIView class. I have code that compiles. My hook implementation
procedure touchesBeganDetour(self: id; _cmd: SEL; touches: NSSet; withEvent: UIEvent); cdecl;
begin
Sleep(1);
end;
And then I tried connecting it in two different ways. Firstly:
constructor TTouchEventListener_IOS.Create;
var
FM1, FM2: Pointer
ViewClass: Pointer;
begin
inherited;
ViewClass := objc_getClass('UIView');
class_addMethod(ViewClass, sel_getUid('touchesBeganDetour:'), @touchesBeganDetour, 'v@:@@');
FM1 := class_getInstanceMethod(ViewClass, sel_getUid('touchesBegan:withEvent:'));
FM2 := class_getInstanceMethod(ViewClass, sel_getUid('touchesBeganDetour:'));
method_exchangeImplementations(FM1, FM2);
end;
This is apparently the standard approach. And the second one:
constructor TTouchEventListener_IOS.Create;
var
FM1
ViewClass: Pointer;
begin
inherited;
ViewClass := objc_getClass('UIView');
FM1 := class_getInstanceMethod(ViewClass, sel_getUid('touchesBegan:withEvent:'));
method_setImplementation(FM1, @touchesBeganDetour);
end;
, . " touchhesBegan: withEvent", . , " DispatchToImportSuper" " Macapi.ObjectiveC.pas". , , - , . , Delphi.
- ?