3 ms·
But it does allow for programmers to add their own ideas. I have a traits implementation where I can inject entire behaviours in a line of code. I am not sure i
by emp 12y ago
But it does allow for programmers to add their own ideas. I have a traits implementation where I can inject entire behaviours in a line of code. I am not sure if this could be done in Swift (haven't had time to research properly).
- mahyarm 12y agoThat's what I mean by implemented better as something that is officially supported. In objective-c it's a hack, it can lead to hidden surprises since code usually doesn't make it obvious that a specific method has been swizzled. And you have to deal with hidden expectations in code that you have no control over.
- emp 12y agoTrue, though then we are waiting and hoping for features. Another example of some runtime fun: my debug build swizzles interceptors for common UI lifecycle and action methods (viewDidLoad, didMoveToParentViewController:, sendAction:to:forEvent:, etc). When I am working on an app with many views, a simple glance at the console shows me what view controller displayed, what action a button fired and so on. Great for getting to relevant code quickly. I don't think I could hope for this as a standard feature of a language.