Closed objcat closed 6 years ago
代码如下
- (NSString *)testSyn123123:(NSString *) msg { return [msg stringByAppendingString:@"[ syn call]"]; } - (NSString *)testSyn:(NSString *) msg { return [msg stringByAppendingString:@"[ syn call]"]; }
解决方法如下 修改一下方法判断依据 代码没怎么读 也没进行啥测试 如果有遇到此问题的人可以改改 不过具体还需要作者本人测试 如果有问题随时找我 = = + (NSString *)methodByNameArg:(NSInteger)argNum selName:(NSString *)selName class:(Class)class { NSString *result = nil; if(class){ NSArray *arr = [JSBUtil allMethodFromClass:class]; for (int i = 0; i < arr.count; i++) { NSString *method = arr[i]; NSArray *tmpArr = [method componentsSeparatedByString:@":"]; NSRange range = [method rangeOfString:@":"]; if (range.length > 0) { NSString *methodName = [method substringWithRange:NSMakeRange(0, range.location)]; if ([methodName isEqualToString:selName] && tmpArr.count == (argNum + 1)) { result = method; return result; } } } } return result; }
解决方法如下 修改一下方法判断依据 代码没怎么读 也没进行啥测试 如果有遇到此问题的人可以改改 不过具体还需要作者本人测试 如果有问题随时找我 = =
+ (NSString *)methodByNameArg:(NSInteger)argNum selName:(NSString *)selName class:(Class)class { NSString *result = nil; if(class){ NSArray *arr = [JSBUtil allMethodFromClass:class]; for (int i = 0; i < arr.count; i++) { NSString *method = arr[i]; NSArray *tmpArr = [method componentsSeparatedByString:@":"]; NSRange range = [method rangeOfString:@":"]; if (range.length > 0) { NSString *methodName = [method substringWithRange:NSMakeRange(0, range.location)]; if ([methodName isEqualToString:selName] && tmpArr.count == (argNum + 1)) { result = method; return result; } } } } return result; }
发现dsbridge里面有个小问题 就是如果一个方法名和另一个方法名是包含关系并且长的方法名在前边会出现方法执行错误问题
代码如下
这时在js中调用testSyn方法就会跳到testSyn123123方法上