Latest0.2.4
Homepagehttps://github.com/ModelRocket/STSwizzle
LicenseMIT
Platformsios 5.0, requires ARC
FrameworksFoundation
Authors

STSwizzle

STSwizzle add several methods on NSObject.
Some methods allows to swizzle methods on a class, others to swizzle methods for a particular instance.

If you are wondering, swizzle is a way to exchange the instructions that will be executed when a method is called.

Swizzle on a class

+ (void)swizzleClassMethod:(SEL)firstSelector withMethod:(SEL)secondSelector;

This method allow you to swizzle two class methods. For example you can swizzle +(void)foo1 and +(void)foo2 so that when the foo1 method is called, the foo2 function is executed, and vice versa.

+ (void)swizzleInstanceMethod:(SEL)firstSelector withMethod:(SEL)secondSelector;

This method allow to swizzle two instance methods. those methods will be swizzle for all the instances of the class.

Swizzle on an instance

- (void)addMethodForSelector:(SEL)selector types:(char*)types implementation:(implementation_block)impl;

This method allow to add a new method to an instance. When the selector passed in parameters is called on that instance, the implementation block in parameters is executed.

- (void)replaceMethodForSelector:(SEL)selector implementation:(implementation_block)impl;

This method allow to replace a method on an instance. When the selector passed in parameters is called on that instance, the implementation block in parameters is instead executed.

Installation

To include this component in your project, I recommend you to use Cocoapods:

  • Add pod "STSwizzle" to your Podfile.

How does it work ?

An article about swizzling will be soon available.

Latest podspec

{
    "name": "QSwizzle",
    "version": "0.2.4",
    "summary": "Several Swizzle methods on a NSObject category.",
    "description": "STSwizzle add several methods on NSObject.nSome methods allows to swizzle methods on a class,nothers to swizzle methods for a particular instance.",
    "homepage": "https://github.com/ModelRocket/STSwizzle",
    "license": "MIT",
    "authors": {
        "iSofTom": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ModelRocket/STSwizzle.git",
        "tag": "0.2.4"
    },
    "platforms": {
        "ios": "5.0"
    },
    "source_files": "QSwizzle/**/*.{h,m}",
    "frameworks": "Foundation",
    "requires_arc": true
}

Pin It on Pinterest

Share This