2014-03-03 15:47:01.631 SHXMLParserApp[2833:c07] -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x81b2e80
2014-03-03 15:47:01.632 SHXMLParserApp[2833:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x81b2e80'
*** First throw call stack:
(0x1c9b012 0x10d8e7e 0x1d264bd 0x1c8abbc 0x1c8a94e 0x51e5 0x48f3 0xbdee59 0xbdcf22 0xbde16a 0xbdcedd 0xbdd055 0xb2a338 0x4618a81 0x4617d33 0x4655e3a 0x1c3d8fd 0x46564bc 0x4656435 0x45403a0 0x1c1ef3f 0x1c1e96f 0x1c41734 0x1c40f44 0x1c40e1b 0x1bf57e3 0x1bf5668 0x2065c 0x2395 0x22d5 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb)
-------------------------------------------------------------------------------------以上是错误信息-------------------------------------------------------------------------------------------
然后更近之后发现是字符串中有objectForKey 然后跟进程序找出报错点 然后自己修改程序源码
原本源码:
+ (NSArray *)convertDictionaryArray:(NSArray *)dictionaryArray toObjectArrayWithClassName:(NSString *)className classVariables:(NSArray *)classVariables
{
NSMutableArray *objectArray = [NSMutableArray array];
for (NSDictionary *dict in dictionaryArray) {
id object = [[NSClassFromString (className)alloc] init];
for (NSString *variable in classVariables) {
[object setValue:[dict objectForKey:variable] forKey:variable];
}
[objectArray addObject:object];
}
return objectArray;
}
修改后的源码:
+ (NSArray *)convertDictionaryArray:(NSArray *)dictionaryArray toObjectArrayWithClassName:(NSString *)className classVariables:(NSArray *)classVariables
{
NSMutableArray *objectArray = [NSMutableArray array];
if (![dictionaryArray isKindOfClass:[NSArray class]]) {
dictionaryArray=[NSArray arrayWithObjects:dictionaryArray, nil];
}
for (NSDictionary *dict in dictionaryArray) {
id object = [[NSClassFromString (className)alloc] init];
for (NSString *variable in classVariables) {
if ([dict isKindOfClass:[NSDictionary class]]) {
[object setValue:[dict objectForKey:variable] forKey:variable];
}
else{
}
}
[objectArray addObject:object];
}
return objectArray;
}