Questions tagged [method-swizzling]

Method swizzling is the process of changing the implementation of an existing method.

Method swizzling is the process of changing the implementation of an existing method, swapping its implementation with another's that have the same signature.

The technique is possible in languages where the method implementation is allowed to be changed at runtime. One example is Objective-C, in which is used by Apple’s Foundation Framework to implement Key-Value Observing.

108 questions
0
votes
2 answers

Stub -[NSDate init]

Stubbing NSDate to return a mock date can easily be done using category except for -[NSDate init]. -[NSDate init] is not called unlike other methods. class_addMethod does not help. method_exchangeImplementations, method_setImplementation on -[NSDate…
-1
votes
1 answer

How to swizzle UIApplication in iOS?

I need to Swizzle UIApplication class methods especially "application:handleOpenURL:". I have added a category class of UIApplication. I have exchanged my own method with the original method but, it never triggered. The Swizzle class called very…
Yuvaraj.M
  • 9,741
  • 16
  • 71
  • 100
-3
votes
1 answer

What is the disadvantage of method swizzling in Objective-C?

What is the disadvantage of method swizzling in Objective-C?
Mayank
  • 643
  • 8
  • 19
1 2 3 4 5 6 7
8