Latest 0.0.1
License NetBSD
Platforms ios


An objective C utility that lets you add a wrapper to any function.

What is it?

Suppose you have the following method


-(void) foo {
  NSLog(@"My name is Mike");

with TheWrapper you can add a wrapper to foo in runtime.
Just add the following code before the first call to the function.


#import "TheWrapper.h"

+(void) initialize {
    [TheWrapper addWrappertoClass:[MyClass class] andSelector:@selector(foo) withPreRunBlock:^(id<NSObject> zelf, id firstArg, ...) {
    andPostRunBlock:^id(id<NSObject> zelf, id functionReturnValue, id firstArg, ...) {

Now, calling foo will print

[self foo];

//My name is Mike

The original function’s return value is accessible to the PostRunBlock via the functionReturnValue parameter.
If you wish to return the original return value, just return it from the PostRunBlock.


NanoProfiler is the first public usage of theWrapper.

Known issues

  1. No arc support
  2. Wrapping a method that is only implemented in superclass results in a EXC_BAD_ACCESS.

Latest podspec

    "name": "theWrapper",
    "version": "0.0.1",
    "summary": "An objective C utility that lets you add a wrapper to any function.",
    "homepage": "",
    "authors": {
        "Tomer Shiri": "[email protected]"
    "source": {
        "git": "",
        "tag": "v0.0.1"
    "platforms": {
        "ios": null
    "source_files": "*.{h,m}",
    "requires_arc": false,
    "license": {
        "type": "NetBSD",
        "file": "LICENSE"

Pin It on Pinterest

Share This