我正在尝试合并 OAuthConsumer 以与 API 交互。当“self”关键字为空时,我遇到了委托问题。
当下面的代码放在唯一的 viewController 内时,一切正常。当代码放在名为 wpOAuth 的类中时,然后从 viewController 调用“self”关键字为空,这会导致此错误: requestTokenTicket:didFinishWithData:]: unrecognized selector sent to instance 0x7172ac0
-(void)getKey:(UIViewController *) uiViewController{
NSLog(@"\n\nGet Key!!!!!");
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:@"fsdfsdsdfsdfsdf"
secret:@"sdfdsfsdfsdf"];
NSURL *url = [NSURL URLWithString:@"http://api-public.netflix.com/oauth/request_token"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:nil // we don't have a Token yet
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[request setHTTPMethod:@"POST"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(requestTokenTicket:didFinishWithData:)
didFailSelector:@selector(requestTokenTicket:didFailWithError:)];
}
- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
if (ticket.didSucceed) {
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
//requestToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
NSLog(@"%@",[[OAToken alloc] initWithHTTPResponseBody:responseBody]);
NSLog(@"\nticket is????????????????????????????= %@ ",ticket.body);
}
}
任何有关 self 关键字为何为空的见解都将不胜感激!
谢谢,4D