Method swizzling

Is there a mechanism to utilize “method swizzling” feature ? As I need to change one of UIApplicationDelegate methods implementation during the runtime.
thanks in advance

1 Like

Any hope ?!
What is wrong with this ?!

Hi,

Method swizzling is a feature of the Objective-C runtime. When you subclass an ObjC class or implement an ObjC Protocol in Java, Nat/J automatically sets up the corresponding Objective-C class at runtime where the ObjC method calls are forwarded to the Java implementations. So theoretically, it should be possible to do method swizzling on this ObjC class, but it is not supported, probably requires changes to Nat/J, and I don’t recommend doing it.

We would need to know more about the problem that you are trying to solve to suggest a better alternative.

Best Regards,
Gergely

thank you.
My problem is that I need to intercept the calls to the methods : applicationDidRegisterForRemoteNotificationsWithDeviceToken & applicationDidFailToRegisterForRemoteNotificationsWithError
in UIApplicationDelegate OBJECT. I’m using the term “intercept” because I don’t have access to the class “Main” itself (in other words, I can’t implement those methods myself) and I only have a reference to this object.

I hope this is clear