过去几天我一直试图让Twitter的OAuth工作在我的iPhone应用程序上,而且我不能为我的生活弄清楚为什么我得到这个错误。我已经改变了一段时间以来的方式,但仍然一无所获。所以我转而希望弄清楚。“无法识别的选择器”错误。无法弄清楚
本教程是linked here。下载应用程序并运行它非常有效。它不适合我。
这是我得到的错误 -
2010-07-25 20:04:52.224 AppTest[4620:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OAToken setVerifier:]: unrecognized selector sent to instance 0x6c2acc0'
谁能告诉我什么,我做错了什么?我使用几乎相同的代码。
编辑:下面的代码,我使用setVerifier:
- (IBAction)finishSetup:(id)sender {
NSString *thePin = [[NSString alloc] initWithString:pinText.text];
NSLog(@"%@", thePin);
if([thePin length] == 7 && [[NSScanner scannerWithString:thePin] scanInt:NULL]) {
loadingView.hidden = NO;
[pinText resignFirstResponder];
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:consumer_key secret:consumer_secret];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/oauth/access_token"];
[accessToken setVerifier:pinText.text];
NSLog(@"Using PIN %@", accessToken.verifier);
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url consumer:consumer token:accessToken realm:nil signatureProvider:nil];
[request setHTTPMethod:@"POST"];
NSLog(@"Getting access token...");
[fetcher fetchDataWithRequest:request delegate:self didFinishSelector:@selector(accessTokenTicket:didFinishWithData:) didFailSelector:@selector(accessTokenTicket:didFailWithError:)];
} else {
loadingView.hidden = YES;
error_alert = [[UIAlertView alloc] initWithTitle:@"TestApp" message:@"The PIN you have entered is invalid. Please try again." delegate:self cancelButtonTitle:@"Cancel Login" otherButtonTitles:@"Try again", nil];
[error_alert show];
[error_alert release];
}
[thePin release];
}
“几乎使用相同的代码”与“使用相同的代码”不一样。如果不同,请将其发布在您的问题中。 – 2010-07-26 00:23:19
这是相同的代码,我的道歉。唯一的区别是该教程不适用于iPhone,而是使用Objective-C和Cocoa。 – 2010-07-26 00:31:51
您应该在您使用' - [OAToken setVerifier:]' – kubi 2010-07-26 00:35:24