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

Can't hook class methods #32

Open
iamredeye opened this issue Dec 1, 2014 · 5 comments
Open

Can't hook class methods #32

iamredeye opened this issue Dec 1, 2014 · 5 comments

Comments

@iamredeye
Copy link

Hello,

I have figured out an issue concerning class method (not instance methods).

I have tried to put this into my code :

[NSJSONSerialization aspect_hookSelector:@selector(JSONObjectWithData:options:error:) withOptions:AspectPositionBefore usingBlock:^(id info, NSData _data, NSJSONReadingOptions opt, NSError *_error){
NSLog(@"JSONObjectWithData:options:error: before | object:%@ | instance:%@ | class:%@",info,[info instance],[[info instance] class]);
} error:NULL];

        [NSJSONSerialization aspect_hookSelector:@selector(JSONObjectWithData:options:error:) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> info, NSData *data, NSJSONReadingOptions opt, NSError **error){
            NSLog(@"JSONObjectWithData:options:error: after | object:%@ | instance:%@ | class:%@",info,[info instance],[[info instance] class]);
        } error:NULL];

The Aspects did not intercept class methods examples set in my AppDelegate for example.
Do you know a solution for this issue ?

Thanks

@steipete
Copy link
Owner

steipete commented Dec 1, 2014

Hmm. Is there any info in the log why this might fail?

@iamredeye
Copy link
Author

I have figured out that I have to use the 1.5 version for that.
But it seems not working on arm64...
Do you have any news when It could be released for arm64 devices / simulators ?

@steipete
Copy link
Owner

steipete commented Dec 1, 2014

Never found the time to dig into that. PR's welcome :)

@iamredeye
Copy link
Author

The version 1.4 works great on arm64 but does not contain Class Hook methods.
The 1.5 doesnt work on arm64 but contains Class Hook Methods.
Is there a way to add just the needed code from 1.5 to the 1.4 to just add on it the class hook methods functionnalities ? I think the problem is with trampoline on arm64

@steipete
Copy link
Owner

steipete commented Dec 1, 2014

Again, I very much welcome pull requests. Currently 1.4 works for me as I use Apects for testing/mocking only - if this changes I'll put it more work.

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