3 ms·
http://nshipster.com/method-swizzling/ http://nshipster.com/method-swizzling/
by bennyg 13y ago
http://nshipster.com/method-swizzling/ http://nshipster.com/method-swizzling/
- babesh 13y agoWas addressing the use of categories to override not method swizzling per se. Oh, I read your link. So you add more behavior to it, not override it completely.
- seanmcdirmid 13y agoIsn't that just monkey patching?
- bennyg 13y agohttp://en.wikipedia.org/wiki/Monkey_patch http://en.wikipedia.org/wiki/Monkey_patch By that link's definition, then yeah, it's basically monkey patching.
- my3681 13y agoI think a lot could be said here for maintainability. As others have mentioned, it really goes a long way to take the time and refactor the class to inherit the extra/common functionality if you are working on a team or working on a project that you know will live a very long time. Swizzling will certainly work, but at what cost to readability, debugging and reuse? That's normally the question I ask before swizzling or doing fancy, dynamic things. Sometimes the quickest or even the most elegant solution isn't necessarily the "best" one. Best being a subjective term, I would say it depends on what you need from your code over time and with whom.