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方法在方法执行之前修改参数 #23

Open
xygkevin opened this issue Jul 14, 2023 · 4 comments
Open

怎么样hook方法在方法执行之前修改参数 #23

xygkevin opened this issue Jul 14, 2023 · 4 comments

Comments

@xygkevin
Copy link

怎么样hook方法在方法执行之前修改参数

@xygkevin
Copy link
Author

比如:

typedef void(^XXURLRequestCompletionBlock)(NSData *, NSURLResponse *, NSError *);

[NSURLSession st_hookInstanceMethod:@selector(dataTaskWithRequest:completionHandler:) option:STOptionBefore usingIdentifier:@"session_before" withBlock:^(id<StingerParams> params, NSMutableURLRequest *request, XXURLRequestCompletionBlock completionHandler){
}];

我想在NSURLSession的dataTaskWithRequest:completionHandler:方法执行之前修改参数,包括request以及completionHandler的实现,以便于在completionHandler调用的时候执行其他处理;

@Fxxxxxx
Copy link

Fxxxxxx commented Apr 26, 2024

可以试下我这个PR的代码,#25

@xygkevin
Copy link
Author

可以试下我这个PR的代码,#25

完全匹配我的需求,经过一段时间的线上运行观察,一切OK

@Fxxxxxx
Copy link

Fxxxxxx commented Jul 25, 2024

哈哈 祝用的开心 😄

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