今はTwitterだけだけど、iOS6でFacebookとか増えるので。
詳しくは
https://developer.apple.com/library/ios/#documentation/Accounts/Reference/ACAccountStoreClassRef/Reference/Reference.html
https://developer.apple.com/library/ios/#documentation/Accounts/Reference/ACAccountClassRef/Reference/Reference.html
ACSample
@implementation ACSample
- (void)sample {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
// 今回はTwitterのアカウント取得するよ
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
if ([accountsArray count] > 0) {
// 複数連携されてる場合もあるよ
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
}
} else {
// ユーザーにアカウントへのアクセス拒否されたりするとこっちに来るよ
}
}];
}
@end