1

我正在尝试从 gmail 帐户获取联系人并收到此错误:

 "ViewController" selector "ticket:finishedWithFeed:" should have 3 arguments
*** Assertion failure in void GTMAssertSelectorNilOrImplementedWithArgs(id, SEL, ...)(), 
/gtm-oauth2/GTMHTTPFetcher.m:1607
 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'callback selector arguments incorrect' 

   -(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:)];
}


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

    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);
    }
}



- (void)viewDidLoad
{
    [super viewDidLoad];
    [self getGoogleContacts];
}
4

1 回答 1

2

看起来 API 需要一个带有三个参数的选择器,第三个参数代表NSError*

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

...

ticket = [service fetchContactFeedForUsername:username delegate:self didFinishSelector:@selector(ticket:finishedWithFeed:error:)];
于 2013-04-24T13:16:04.093 回答