0

Gdata を使用して、Gmail アカウントから連絡先を取得しています。ユーザーの詳細 (名前など) を取得することはできますが、メールを取得しようとすると、次のエラーが表示されます。

-[GDataEntryBase emailAddresses]: unrecognized selector sent to instance

私が読んだことから、私は正しい方法でそれをやっています。私は何が欠けていますか?

コード:

      -(void)getGoogleContacts {

        GDataServiceGoogleContact *service =
        [[GDataServiceGoogleContact alloc] init];

        NSString *username = @"username@gmail.com";
        NSString *password = @"pass";

        service = [[GDataServiceGoogleContact alloc] init];

        [service setUserAgent:@"McGraggerSoft-GoogleContactUtility-1.0"];
        [service setUserCredentialsWithUsername:username password:password];

        ticket = [service fetchContactFeedForUsername:username delegate:self didFinishSelector:@selector(ticket:finishedWithFeed:error:)];
    }


- (void)ticket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedContact *)feed error:(NSError *)error
    {

        if ([[feed entries] count] > 0) {

            GDataEntryContact *firstContact = [[feed entries] objectAtIndex:0];
            GDataTextConstruct *titleTextConstruct = [firstContact title];
            NSString *title = [titleTextConstruct stringValue];    
            NSLog(@"first contact's title:%@", title);
           GDataEmail *email = [[firstContact emailAddresses] objectAtIndex:0]; //<-- Crash
          //NSString *ContactEmail = [email address];
          //NSLog(@"ContactEmail: %@",ContactEmail);
        }
    }

これは私が使用しているプロジェクトです: https://github.com/819419423/GDataWithGTMOauth2Example メインコントローラーのすべてを削除し、上記のメソッドを追加してエラーを取得できます。

4

3 に答える 3