Latest 0.1.0
Homepage https://github.com/Wondermall/Swizzler
License MIT
Authors

Build Status
Version
License
Platform
Twitter: @zats

Usage

Vanilla swizzling:

SEL setObjectSelector = @selector(setObject:atIndex:);
[NSArray wml_replaceInstanceMethod:setObjectSelector withBlock:^(NSArray *self, id object, NSInteger index){
    // your logic...
}];

Or if you want to call the original method from your new implementation:

__block IMP originalIMP = [NSArray wml_replaceInstanceMethod:setObjectSelector withBlock:^(NSArray *self, id object, NSInteger index){
    // hopefully this not what you're doing
    originalIMP(self, setObjectSelector, object, self.count - index - 1);
}];

Restore the original implementation, once you’re done with swizzling:

[WMLSwizzler replaceClassMethod:setObjectSelector inClass:[NSArray class] withImplementation:originalIMP];

Why

TL;DR

If you’re swizzling "the old" way, you might run into issues since you new selector xyz_swizzledMethod might be passed when you call the original implementation. Besides, the block-based API is nicer and more concise.

Details

Swizzling is all fun and giggles until you screw it up. Please refer to these articles for more info:

Installation

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

pod "Swizzler"

Author

Sash Zats, [email protected]

License

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

Latest podspec

{
    "name": "Swizzler",
    "version": "0.1.0",
    "summary": "Swizzling done right",
    "description": "                       Swizzling done right:nn                       * Swizzling done rightn                       * Blocks APIn                       * Original implementation on your fingertipsn",
    "homepage": "https://github.com/Wondermall/Swizzler",
    "license": "MIT",
    "authors": {
        "Sash Zats": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Wondermall/Swizzler.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/zats",
    "requires_arc": true,
    "source_files": "Pod/**/*"
}

Pin It on Pinterest

Share This