Declared in NSObject+DTRuntime.h

Overview

Methods to dynamically modify objects at runtime

Class Methods

addInstanceMethodWithSelectorName:block:

Adds a new instance method to a class. All instances of this class will have this method.

+ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void ( ^ ) ( id ))block

Parameters

selectorName

The name of the method.

block

The block to execute for the instance method, a pointer to the instance is passed as the only parameter.

Return Value

YES if the operation was successful

Discussion

The block captures self in the calling context. To allow access to the instance from within the block it is passed as parameter to the block.

Declared In

NSObject+DTRuntime.h

swizzleClassMethod:withMethod:

Exchanges two class method implementations. After the call methods to the first selector will now go to the second one and vice versa.

+ (void)swizzleClassMethod:(SEL)selector withMethod:(SEL)otherSelector

Parameters

selector

The first method

otherSelector

The second method

Declared In

NSObject+DTRuntime.h

swizzleMethod:withMethod:

Exchanges two method implementations. After the call methods to the first selector will now go to the second one and vice versa.

+ (void)swizzleMethod:(SEL)selector withMethod:(SEL)otherSelector

Parameters

selector

The first method

otherSelector

The second method

Declared In

NSObject+DTRuntime.h

Instance Methods

addDeallocBlock:

Adds a block to be executed as soon as the receiver’s memory is deallocated

- (void)addDeallocBlock:(void ( ^ ) ( ))block

Parameters

block

The block to execute when the receiver is being deallocated

Declared In

NSObject+DTRuntime.h