From 71e63c6d41578316a622f6d28ad56abe378229d2 Mon Sep 17 00:00:00 2001 From: masakih Date: Sun, 14 Sep 2014 14:14:53 +0900 Subject: [PATCH] =?utf8?q?Tweet=E5=87=BA=E6=9D=A5=E3=81=AA=E3=81=84?= =?utf8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KCD/HMScreenshotWindowController.m | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/KCD/HMScreenshotWindowController.m b/KCD/HMScreenshotWindowController.m index 2b679469..7125a894 100644 --- a/KCD/HMScreenshotWindowController.m +++ b/KCD/HMScreenshotWindowController.m @@ -162,6 +162,26 @@ } - (BOOL)canTweet { + ACAccountType *twitterType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; + if(![twitterType accessGranted]) { + [self.accountStore requestAccessToAccountsWithType:twitterType + options:nil + completion:^(BOOL granted, NSError *error) { + if(!granted) { + NSLog(@"No access granted"); + } else { +// NSLog(@"succsess"); + } + }]; + } + NSArray *accounts = [self.accountStore accountsWithAccountType:twitterType]; + if([accounts count] == 0) { + NSLog(@"twitter account not avail."); + NSLog(@"Accounts -> %@", self.accountStore.accounts); + return NO; + } + self.availableTwitter = YES; + return self.availableTwitter && self.leaveLength >= 0; } - (BOOL)canSave @@ -276,12 +296,6 @@ - (void)checkShortURLLength { ACAccountType *twitterType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; - NSArray *accounts = [self.accountStore accountsWithAccountType:twitterType]; - if([accounts count] == 0) { - NSLog(@"twitter account not avail."); - return; - } - self.availableTwitter = YES; SLRequestHandler requestHandler = ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { -- 2.11.0