Latest 1.0.0
Homepage https://github.com/remirobert/RROLoadSwizzle
License MIT
Platforms ios 10.0, requires ARC
Authors

buid status codecov

Used to assist in unit testing.
Check Tests for usage.


//A function which is the implementation of original method. 
//The function must take at least two arguments—self and _cmd.
void (*gOriginalViewDidLoad)(id, SEL);

- (void)tearDown {
    RRO_REVERT_SWIZZLE_ALL_METHOD([UIViewController class]);
}

- (void)testThatViewDidLoadIsCalledWhenShowWindow {
  __block BOOL isViewDidLoadCalled = NO;

  void (^viewDidLoadBlock)(UIViewController *, SEL) = ^void (UIViewController *nav, SEL _cmd) {
    isViewDidLoadCalled = true;
    NSLog(@"viewDidLoad called here");

    //call original @selector(viewDidLoad) if needed
    gOriginalViewDidLoad(nav, _cmd); 
  };

  RRO_SWIZZLE_BLOCK([UIViewController class], @selector(viewDidLoad), viewDidLoadBlock, &gOriginalViewDidLoad);

  UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  window.rootViewController = [[UIViewController alloc] init];
  [window makeKeyAndVisible];

  XCTAssertTrue(isViewDidLoadCalled);
}

Latest podspec

{
    "name": "RROLoadSwizzle",
    "version": "1.0.0",
    "summary": "Simple NSObject category for swizzle method implementation and revert to the original",
    "homepage": "https://github.com/remirobert/RROLoadSwizzle",
    "license": "MIT",
    "authors": {
        "Remi ROBERT": "[email protected]"
    },
    "source": {
        "git": "https://github.com/remirobert/RROLoadSwizzle.git",
        "tag": "1.0.0"
    },
    "source_files": "RROLoadSwizzle/**/*.{h,m}",
    "private_header_files": "RROLoadSwizzle/RROSwizzlingInfoStore.h",
    "requires_arc": true,
    "platforms": {
        "ios": "10.0"
    },
    "ios": {
        "frameworks": "Foundation"
    }
}

Pin It on Pinterest

Share This