4

나는 los 6와 twitter를 통합하여 slcomposeviewcontroller를 사용하여 트윗을 보내려고하지만 트위터 계정에서 사용자 정보를 얻는 방법을 알 수 없습니다.ios 6의 트위터에서 사용자 정보를 얻는 방법은 무엇입니까?

아무도 도와 줄 수 있습니까?

+0

당신이 한 일과 원하는 것을 더 잘 설명해 주실 수 있습니까? http://www.whathaveyoutried.com –

+0

다음의 사용자 이름과 번호를 표시하고 싶습니다. –

답변

11

잘못된 길을 가고 있지만 잘못된 프레임 워크를 사용하고있었습니다. 소셜 프레임 워크의 SLComposeViewController 클래스는 공유 용으로 만 사용됩니다. 현재 로그인 한 계정에 대한 정보를 얻으려면 Accounts Framework을 사용해야합니다.

#import <Accounts/Accounts.h> 


- (void)getTwitterAccountInformation 
{ 
    ACAccountStore *accountStore = [[ACAccountStore alloc] init]; 
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 

    [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) { 
     if(granted) { 
      NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; 

      if ([accountsArray count] > 0) { 
       ACAccount *twitterAccount = [accountsArray objectAtIndex:0]; 
       NSLog(@"%@",twitterAccount.username); 
       NSLog(@"%@",twitterAccount.accountType); 
      } 
     } 
    }]; 
} 
관련 문제