Aspects icon indicating copy to clipboard operation
Aspects copied to clipboard

why not hook NSBundle infoDictionary function?

Open NarutoYq opened this issue 10 years ago • 1 comments

[NSBundle aspect_hookSelector:@selector(infoDictionary) withOptions:AspectPositionInstead usingBlock:^(id<AspectInfo> 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

NarutoYq avatar Dec 11 '15 02:12 NarutoYq

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

steipete avatar Dec 11 '15 03:12 steipete