Monkey-Patching iOS with Objective-C Categories

Monkey-Patching iOS with Objective-C Categories Part III: Swizzling

Originally posted on Carbon Five’s Blog. Have you ever wanted to introduce new functionality to base classes in the iOS SDK? Or just make them work a little differently? In order to do so, you must enter the wild and dangerous world of monkey-patching. In this series of posts, we’ll show how to monkey-patch in Objective-C through categories to add and change methods, to add new instance variables and properties, and introduce swizzling, a technique that allows us to extend and preserve existing functionality.

Monkey-Patching iOS with Objective-C Categories Part II: Adding Instance Properties

Originally posted on Carbon Five’s Blog. Have you ever wanted to introduce new functionality to base classes in the iOS SDK? Or just make them work a little differently? In order to do so, you must enter the wild and dangerous world of monkey-patching. In this series of posts, we’ll show how to monkey-patch in Objective-C through categories to add and change methods, to add new instance variables and properties, and introduce swizzling, a technique that allows us to extend and preserve existing functionality.

Monkey-Patching iOS with Objective-C Categories Part I: Simple Extensions and Overrides

Originally posted on Carbon Five’s Blog. Have you ever wanted to introduce new functionality to base classes in the iOS SDK? Or just make them work a little bit differently? In order to do so, you must enter the wild and dangerous world of monkey-patching. Monkey-patching is extending or modifying the behavior of code at runtime without changing its original source code. You can monkey-patch any code, it doesn’t matter whether it’s your own code or not.