gpt4 book ai didi

iphone - iOS 5 中的 Twitter 用户 ID

转载 作者:IT王子 更新时间:2023-10-29 08:13:47 25 4
gpt4 key购买 nike

我在 iOS 5 中使用以下代码从 Twitter 获取用户详细信息。

if ([TWTweetComposeViewController canSendTweet]) 
{
// Create account store, followed by a Twitter account identifer
account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

// Request access from the user to use their Twitter accounts.
[account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error)
{
// Did user allow us access?
if (granted == YES)
{
// Populate array with all available Twitter accounts
arrayOfAccounts = [account accountsWithAccountType:accountType];
[arrayOfAccounts retain];

// Populate the tableview
if ([arrayOfAccounts count] > 0)
[self performSelectorOnMainThread:@selector(updateTableview) withObject:NULL waitUntilDone:NO];
}
}];
}

//

-(void)updateTableview
{

numberOfTwitterAccounts = [arrayOfAccounts count];
NSLog(@"Twiter details-- %@",[arrayOfAccounts objectAtIndex:0]);

}

在我的 NSLog 控制台中,我得到如下输出:

Twiter details-- type:com.apple.twitter  
identifier: E8591841-2AE0-4FC3-8ED8-F286BE7A36B0
accountDescription: @Sadoo55
username: sadukoyghdkwed@gmail.com
objectID: x-coredata://F8059811-CFB2-4E20-BD88-F4D06A43EF11/Account/p8
enabledDataclasses: {(
)}
properties: {
"user_id" = 308905856;
}
parentAccount: (null)
owningBundleID:com.apple.Preferences

我想从中获取“user_id”。如何获取“user_id”(即 308905856)?

最佳答案

这是我在 iOS5 和 iOS6 中获取 user_id 所做的。

    NSDictionary *tempDict = [[NSMutableDictionary alloc] initWithDictionary: 
[twitterAccount dictionaryWithValuesForKeys:[NSArray arrayWithObject:@"properties"]]];
NSString *tempUserID = [[tempDict objectForKey:@"properties"] objectForKey:@"user_id"];

关于iphone - iOS 5 中的 Twitter 用户 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9080135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com