将现有OAuth凭据迁移到ACAccountStore时出错

我在将现有的OAuth凭据迁移到iOS 5中的ACAccountStore时遇到了问题。

ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; ACAccount *account = [[ACAccount alloc] initWithAccountType:accountType]; ACAccountCredential *credential = [[ACAccountCredential alloc] initWithOAuthToken:savedToken tokenSecret:savedSecret]; [account setCredential:credential]; [accountStore saveAccount:account withCompletionHandler:^(BOOL success, NSError *error) { if (error) { NSLog(@"error saving account: %@", error.description); } NSLog(@"saved account? %d", success); }]; 

最终的结果是:

 2011-10-17 19:09:32.927 League[13731:1b803] error saving account: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn't be completed. (NSURLErrorDomain error -1012.)" 2011-10-17 19:09:32.927 League[13731:1b803] saved account? 0 

此错误信息是由使用不正确的标记/秘密组合导致的。 我错误地修剪了OAuth令牌的user_id前缀。