Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以hook具体的block吗? #1

Open
LZRight123 opened this issue May 27, 2019 · 1 comment
Open

可以hook具体的block吗? #1

LZRight123 opened this issue May 27, 2019 · 1 comment

Comments

@LZRight123
Copy link

[center addObserverForName:NSCurrentLocaleDidChangeNotification object:nil
    queue:mainQueue usingBlock:^(NSNotification *note) {
 
        NSLog(@"The user's locale changed to: %@", [[NSLocale currentLocale] localeIdentifier]);
    }];

比如我想直接hook这个block

^(NSNotification *note) {

    NSLog(@"The user's locale changed to: %@", [[NSLocale currentLocale] localeIdentifier]);
}
@youngsoft
Copy link
Owner

非常抱歉,这个是一个通用的HOOK机制,对于Hook特定的block对象可能会比较麻烦,如果确实要hook时你需要持有某个block对象,然后在那个HOOK函数中进行特定对象的判断。目前这个机制主要用于一些日志记录和监控用,不是用于特定的HOOK某个对象用。其他有一些可以HOOK特定对象的开源库您可以找找。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants