使用中遇到的问题
zhouwude opened this issue · 1 comments
zhouwude commented
if (action == nil) {
return false;
}
SEL sel = nil;
if (paramDict == nil || paramDict.allKeys.count == 0) {
if (callbackKey.length == 0) {
sel = NSSelectorFromString([NSString stringWithFormat:@"%@", action]);
} else {
sel = NSSelectorFromString([NSString stringWithFormat:@"%@WithCallback:", action]);
}
} else {
if (callbackKey.length == 0) {
sel = NSSelectorFromString([NSString stringWithFormat:@"%@:", action]);
} else {
sel = NSSelectorFromString([NSString stringWithFormat:@"%@:callback:", action]);
}
}
if (![self respondsToSelector:sel]) {
return NO;
}
[self runSelector:sel withObjects:[NSArray arrayWithObjects:paramDict, callbackKey, nil]];
AHLog(@"agruments is %@",[NSArray arrayWithObjects:paramDict, callbackKey, nil]);
return YES;
这块的代码有点疑问?
这里定义的sel 跟参数是不是对不上, 当paramDict 定义为空且有callback的时候 sel为actionWithCallback:就一个参数 但是runSelector参数实际为两个造成exception。同理paramDict 为nil的时候 callback不为nil的时候NSArray arrayWithObjects:paramDict, callbackKey, nil]实际为空数组,也会有异常。