嗨,我正在尝试制作一个以选择器为参数的 Objective-C 方法。但我不断收到“发送到实例的无法识别的选择器”错误消息。我正在执行以下操作:
这是带有选择器参数的方法:
-(void)createURL: (SEL) selector{
dispatch_sync(kBgQueue,^{
NSData* data = [NSData dataWithContentsOfURL: wcfURL];
[self performSelectorOnMainThread:@selector(selector)
withObject:data waitUntilDone:YES];
});
}
这是我想成为选择器的方法:
-(void)fetchedUserType:(NSData *)responseData{
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData
options:kNilOptions
error:&error];
userType = [json objectForKey:@"getUserTypeResult"];
}
这就是我调用我的方法的地方:
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *url = [NSString stringWithFormat:@"http://10.211.55.3:1234/Service1.svc/getUserType/%@", userEmail];
wcfURL = [[NSURL alloc]initWithString:url];
SEL sel = NSSelectorFromString(@"fetchedUserType:");
[self createURL:sel];
}