Latest 0.4.0
Homepage https://github.com/OliverLetterer/imp_implementationForwardingToSelector
License MIT
Platforms ios 7.0, requires ARC
Frameworks Foundation
Authors

Version
Platform
License Badge

imp_implementationForwardingToSelector is a trampoline that forwards an objc message to a different selector.

Installation

imp_implementationForwardingToSelector is available through CocoaPods, to install
it simply add the following line to your Podfile:

pod "imp_implementationForwardingToSelector"

How it works

Message forwarding

imp_implementationForwardingToSelector is a custom trampoline (you can read about trampolines here) which can forward any objc message to a new selector.

IMP imp_implementationForwardingToSelector(SEL forwardingSelector, BOOL returnsAStructValue);

Here is an example

IMP forwardingImplementation = imp_implementationForwardingToSelector(@selector(setCenter:), NO);
class_addMethod([UIView class], @selector(thisSetCenterDoesNotExistYet:), forwardingImplementation, typeEncoding);

and suddenly every instance of UIView responds to -[UIView thisSetCenterDoesNotExistYet:] and forwards this message to -[UIView setCenter:]. If you would like some more information about trampolines and maybe a blog post like Writing custom trampolines for beginners and all the pitfalls, hit me up on Twitter.

Limitations

imp_implementationForwardingToSelector is written in raw assembly which is currently only available on i386, armv7, armv7s and arm64.

Author

Oliver Letterer

License

imp_implementationForwardingToSelector is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "imp_implementationForwardingToSelector",
    "version": "0.4.0",
    "summary": "A trampoline that forwards an objc message to a different selector.",
    "homepage": "https://github.com/OliverLetterer/imp_implementationForwardingToSelector",
    "license": "MIT",
    "authors": {
        "Oliver Letterer": "[email protected]"
    },
    "source": {
        "git": "https://github.com/OliverLetterer/imp_implementationForwardingToSelector.git",
        "tag": "0.4.0"
    },
    "social_media_url": "https://twitter.com/oletterer",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "frameworks": "Foundation",
    "source_files": "Source/*.{h,m,s}"
}

Pin It on Pinterest

Share This