3 ms·
This kind of stuff used to work in Objective-C too, but it was removed step by step for performance reasons. If you allow it, for every call you do to such an o
by brodo 6y ago
This kind of stuff used to work in Objective-C too, but it was removed step by step for performance reasons. If you allow it, for every call you do to such an object you have to first check if the method exits on it or somewhere up the inheritance chain. You can cache of course, but adding or removing a method to an object invalidates the cache for the object itself and everything that inherits from it's class.
- pulse7 6y agoIn debugging mode it can work a bit slower and allow all this...
- drkrab 6y agoIn a modern JIT with dynamic decompilation you can do these things in place, because the compiler essentially has global knowledge. The only real issue is to define the semantics (and then implement it of course). Objective-C is AOT compiled so the runtime checks are needed all the time.
- saagarjha 6y agoI'm not sure why you think it's been removed? The entire runtime is still there…the cache you're talking about still exists and is hit for every method call.
- brodo 6y agoI wanted to do method swizzling in Objective C around 10 years ago. The methods for removing/replacing selectors where deprecated around that time.
- saagarjha 6y agoThey are not deprecated: https://developer.apple.com/documentation/objectivec/objective-c_runtime https://developer.apple.com/documentation/objectivec/objecti....