Latest 1.2
Homepage https://github.com/silence0201/Invoker
License MIT
Platforms ios 7.0, requires ARC
Authors

Language
License

Invoker for Objective-C
集合OCRuntime来调用私有函数

使用说明

安装

将项目中Invoker目录导入项目中

Pod安装

pod 'Invoker', '~> 1.0'

使用

具体查看ViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];

    // 调用公开的方法
    CGRect rect = [[self invoke:@"aRect"] CGRectValue];
    NSLog(@"rect: %@", NSStringFromCGRect(rect));

    // 调用公开的方法并传入参数
    [self.view invoke:@"setBackgroundColor:" arguments:@[ [UIColor whiteColor] ]];
    [self.view invoke:@"setAlpha:" arguments:@[@(0.5)]];
    [UIView animateWithDuration:3 animations:^{
        [self.view invoke:@"setAlpha:" arguments:@[@(1.0)]];
    }];

    // 调用私有方法
    int sizeClass = [[self invoke:@"_verticalSizeClass"] intValue];
    NSLog(@"sizeClass: %d", sizeClass);

    // 调用私有方法并传入参数
    [self invoke:@"_setShowingLinkPreview:" arguments:@[@(NO)]];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self invoke:@"_setShowingLinkPreview:" arguments:@[@(YES)]];
    });

    // 调用类方法
    UIEdgeInsets insets = [[self.class invoke:@"aInsets:" arguments:@[@"Test"]] UIEdgeInsetsValue];
    NSLog(@"insets: %@", NSStringFromUIEdgeInsets(insets));

    // 调用类方法并传入参数
    UIColor *color = [UIColor invoke:@"colorWithRed:green:blue:alpha:" arguments:@[@(0), @(0.5), @(1),@(1)]] ;
    NSLog(@"color: %@", color);
}

Invoker

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

Latest podspec

{
    "name": "Invoker",
    "version": "1.2",
    "summary": "Objective-C Invoker.",
    "description": "Eeay way to call private Method",
    "homepage": "https://github.com/silence0201/Invoker",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Silence": "[email protected]"
    },
    "social_media_url": "https://twitter.com/Silencee0201",
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/silence0201/Invoker.git",
        "tag": "1.2"
    },
    "source_files": [
        "Invoker",
        "Invoker/**/*.{h,m}"
    ],
    "exclude_files": "Invoker/Exclude",
    "public_header_files": "Invoker/**/*.h",
    "requires_arc": true
}

Pin It on Pinterest

Share This