【发布时间】:2014-05-30 11:35:32
【问题描述】:
我正在尝试在 iOS 应用中创建 NSMutableDictionary 并覆盖默认 NSDictionary 的部分内容。我使用的代码编译没有问题,但我显然遗漏了一些东西。
我有这个NSLog 的一个函数:
Status: 0x22a1b740> initWithDictionary:{
ability = (
{
id = 1001;
}
);
c = 10000;
l = 1;
p = 4;
t = 5;
}]
我尝试使用此代码创建NSMutableDictionary 以将键“c”更改为 20000;
%hook Status
-(id)initWithDictionary:(id)fp8 {
NSMutableDictionary *newDict = [[NSMutableDictionary alloc] init];
NSDictionary *oldDict = (NSDictionary *)[fp8 objectAtIndex:0];
[newDict addEntriesFromDictionary:oldDict];
[newDict setObject:@"20000" forKey:@"c"];
[fp8 replaceObjectAtIndex:0 withObject:newDict];
[newDict release];
}
return %orig;
}
%end
我收到此崩溃报告:
May 30 13:02:54 Fangs-iPad ReportCrash[2404]: -[__NSDictionaryI objectAtIndex:]: unrecognized selector sent to instance 0x22bd6910
May 30 13:02:54 Fangs-iPad ReportCrash[2404]: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI objectAtIndex:]: unrecognized selector sent to instance 0x22bd6910'
*** First throw call stack:
(0x322e73e7 0x3a181963 0x322eaf31 0x322e964d 0x32241208 0x557d98 0x56791c 0x16789d 0x16530f 0x1644dd 0x16851f 0x7af3f 0x340ff471 0x322bc941 0x322bac39 0x322baf93 0x3222e23d 0x3222e0c9 0x35de933b 0x3414a2b9 0x7425f 0x74218)
你知道我在这里做错了什么吗?非常感谢任何帮助:)
【问题讨论】:
-
谷歌“无法识别的选择器”并研究几个“命中”。然后,如果你想不通,回来把你不明白的地方解释清楚。
标签: ios objective-c