Created
August 6, 2016 05:24
-
-
Save niwatako/5ffcf2f16ae214068d5e430f9f78b5c4 to your computer and use it in GitHub Desktop.
TimelineViewControllerのviewDidLoadでTwitterアカウントをOSから取得 #CodePiece #realm_swift #realm_jp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| let accountStore = ACAccountStore() | |
| let accountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter) | |
| accountStore.requestAccessToAccountsWithType(accountType, options: nil) { (granted, error) -> Void in | |
| if granted { | |
| let accounts = accountStore.accountsWithAccountType(accountType) | |
| if let account = accounts.first as? ACAccount { | |
| self.account = account | |
| self.getHomeTimeline() | |
| } else { | |
| self.showAlert("No Twitter account") | |
| } | |
| } else { | |
| self.showAlert("No account access") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment