OSDN Git Service

Tweet出来ない問題を解消
authormasakih <masakih@users.sourceforge.jp>
Sun, 14 Sep 2014 05:14:53 +0000 (14:14 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 14 Sep 2014 05:14:53 +0000 (14:14 +0900)
KCD/HMScreenshotWindowController.m

index 2b67946..7125a89 100644 (file)
 }
 - (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
 - (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) {