1

私は 1 つの viewController を持つアプリケーションで GMTOAuth2 を使用していますが、それは正常に動作します。次に、さらに多くの viewController を含む別のアプリケーションに同じコードを追加します。ユーザー名とパスワードのテキストフィールドを含む webView をロードしますが、このビューで何かをクリックするとクラッシュしますスレッド 1: void SendDelegateMessage(NSInvocation *) を使用した EXC_BAD_ACCESS (コード = 2、アドレス = 0xbf7ffffc): デリゲート (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) は、10 秒待った後に戻ることができませんでした。メイン実行ループ モード: コンソールの kCFRunLoopDefaultMode。認証部分の私のコードは次のようになります。

- (void)awakeFromNib {
    [super awakeFromNib];
    GTMOAuth2Authentication *auth = nil;
    auth = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName
                                                             clientID:kMyClientID
                                                         clientSecret:kMyClientSecret];
    if (auth)
    {
        [auth authorizeRequest:nil
                  delegate:self
         didFinishSelector:@selector(authentication:request:finishedWithError:)];
    }


}


- (void)signInToGoogle {
    [self signOut];

    NSString *keychainItemName = kKeychainItemName;

    NSString *scope = @"https://spreadsheets.google.com/feeds https://docs.google.com/feeds";
    NSString *clientID = kMyClientID;
    NSString *clientSecret = kMyClientSecret;

    if ([clientID length] == 0 || [clientSecret length] == 0) {
        NSString *msg = @"The sample code requires a valid client ID and client secret to sign in.";
        [self displayAlertWithMessage:msg];
        return;
    }

    SEL finishedSel = @selector(viewController:finishedWithAuth:error:);

    GTMOAuth2ViewControllerTouch *viewController = [[GTMOAuth2ViewControllerTouch alloc]     initWithScope:scope
                                                                                              clientID:clientID
                                                                                          clientSecret:clientSecret
                                                                                  keychainItemName:keychainItemName
                                                                                  finishedSelector:finishedSel];
                                                                                          delegate:self
    [self presentViewController:viewController animated:YES completion:^{}];

    [[self navigationController] pushViewController:viewController animated:YES];


}

- (void)authentication:(GTMOAuth2Authentication *)auth
           request:(NSMutableURLRequest *)request
     finishedWithError:(NSError *)error {
    if (error != nil) {
        NSLog(@"error!");
    } else {
        [self isAuthorizedWithAuthentication:auth];
        self.auth = auth;    
    }
}

そして、最初のアプリケーションから 2 番目のアプリケーションに同じクラスをコピーし、まったく同じ nib ファイルを作成しました。

4

0 に答える 0