oauth_token=requestkey&oauth_token_secret=requestsecret
如何使用 NSScanner 获取“requestkey”和“requestsecret”。我似乎无法实现它。
NSScanner* scanner = [NSScanner scannerWithString:string];
NSString *oauth_token = @"oauth_token=";
NSString *oauth_token_secret = @"oauth_token_secret=";
[scanner setCharactersToBeSkipped:nil];
NSString *token;
NSString *key;
while (![scanner isAtEnd]) {
[scanner scanString:oauth_token intoString:NULL];
[scanner scanUpToCharactersFromSet:[NSCharacterSet characterSetWithCharactersInString:@"&"] intoString:&token];
[scanner scanUpToString:oauth_token_secret intoString:NULL];
[scanner scanUpToString:oauth_token intoString:&key];
NSLog(@"token%@", token);
NSLog(@"key %@", key);
//token requestkey
//key oauth_token_secret=requestsecret
}
我似乎无法弄清楚为什么它是空的。谢谢!