Open wangkeshuai opened 5 years ago
无法复现?
@wangkeshuai 怎么解决的啊
因为在swift里使用NSClassFromString需要加上项目名:NSClassFromString("(workName).(className)") 我的解决方办法是:swift和OC进行混编,Target_NoTargetAction用OC写,然后在OC的代码里再进行一次跳转。
`
@implementation Target_NoTargetAction
-(void)Action_response:(NSDictionary )params{ NSMutableDictionary dic = [NSMutableDictionary dictionaryWithDictionary:params]; dic[kCTMediatorParamsKeySwiftTargetModuleName] = @"workName"; [[CTMediator sharedInstance] performTarget:@"Target" action:@"action" params:dic shouldCacheTarget:NO]; }
@end `
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
(void)NoTargetActionResponseWithTargetString:(NSString )targetString selectorString:(NSString )selectorString originParams:(NSDictionary )originParams { SEL action = NSSelectorFromString(@"Action_response:"); NSObject target = [[NSClassFromString(@"Target_NoTargetAction") alloc] init];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; params[@"originParams"] = originParams; params[@"targetString"] = targetString; params[@"selectorString"] = selectorString;
[self safePerformAction:action target:target params:params]; }
用swift 写的Target_NoTargetAction 就调用不了哟