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

why not hook NSBundle infoDictionary function? #74

Open
NarutoYq opened this issue Dec 11, 2015 · 1 comment
Open

why not hook NSBundle infoDictionary function? #74

NarutoYq opened this issue Dec 11, 2015 · 1 comment

Comments

@NarutoYq
Copy link

[NSBundle aspect_hookSelector:@selector(infoDictionary) withOptions:AspectPositionInstead usingBlock:^(id aspectInfo) {
NSDictionary *dictInfoDictionary;
NSInvocation *invocationInfoDictionary = aspectInfo.originalInvocation;
[invocationInfoDictionary invoke];
[invocationInfoDictionary getReturnValue:&dictInfoDictionary];
NSMutableDictionary *dictInfoDictionaryNew =[NSMutableDictionary dictionaryWithDictionary:dictInfoDictionary];
dictInfoDictionaryNew[@"CFBundleIdentifier"] = @"com.naruto1.demo1";
NSLog(@"[%s,%d] dictInfoDictionary:%@",FUNCTION,LINE,dictInfoDictionaryNew);
[invocationInfoDictionary setReturnValue:&dictInfoDictionaryNew];
} error:NULL];

when I write this code:
NSLog(@"[%s,%d] dictInfoDictionary:%@",FUNCTION,LINE,[[NSBundle mainBundle] infoDictionary]);

console:
*** -[__NSDictionaryM retain]: message sent to deallocated instance 0x155ef1580

@steipete
Copy link
Owner

Aspects is open source - I welcome you to debug and provide a pull request for this.

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