Facebook-iOs-API Как получить ответ в пользовательской функции - PullRequest
0 голосов
/ 26 октября 2011

Как отловить ответ в пользовательской функции? В основном ответ получает:

- (void)request:(FBRequest *) request didReceiveResponse:(NSURLResponse *)response{
NSLog(@"I have some information");
//  [wait stopAnimating];
  //wait.hidden;
}

  - (void)request:(FBRequest *) request didLoad:(id)result{
   if ([result isKindOfClass:[NSArray class]]){
            result = [result objectAtIndex:0];
    } 
    else{
      // dictionaryWithNames = result;
         infoStatus.text = [result objectForKey:@"name"];
     infiId.text = [result objectForKey:@"id"];
}
if ([result objectForKey:@"data"]){
    arrayWithFriends = [result objectForKey:@"data"];
    if (arrayWithFriends != nil) {
    for (NSDictionary *output in arrayWithFriends){
        NSString *namaFriends = [output objectForKey:@"name"];
        NSLog(@"Your Friend %@", namaFriends);
        infoStatus.text = @"If you could see konsole... You can't";
        continue;
        } 
    } else {
        infoStatus.text = @"You Haven't Got friends or Mutuals";
    }
}

}

Но мне нужна другая функция, потому что невозможно (или слишком сложно) получить все ответы, которые мне нужны, используя только несколько шаблонов в этой функции.

1 Ответ

0 голосов
/ 01 ноября 2011

вы можете использовать ту же схему, что и разработчики facebook в своем примере приложения здесь

https://github.com/facebook/wishlist-mobile-sample/blob/master/iOS/Wishlist/Wishlist/HomeViewController.m

они создают переменную currentAPIcall и заполняют ее в зависимости от запроса следующим образом:

/**
* Make a Graph API Call to get information about the current logged in user.
*/
- (void) apiFQLIMe {

    currentAPICall = kAPIFQLMe;
    // Using the "pic" picture since this currently has a maximum width of 100 pixels

    // and since the minimum profile picture size is 180 pixels wide we should be able
    // to get a 100 pixel wide version of the profile picture

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:

                                   @"SELECT uid, name, pic FROM user WHERE uid=me()", @"query",

                                   nil];
    [facebook requestWithMethodName:@"fql.query"

                                     andParams:params
                                 andHttpMethod:@"POST"

                                   andDelegate:self];
}




- (void)request:(FBRequest *)request didLoad:(id)result {
    [self hideActivityIndicator];
    if ([result isKindOfClass:[NSArray class]]) {
        result = [result objectAtIndex:0];
    }
    switch (currentAPICall) {
        case kAPIFQLMe:
        {
            // This callback can be a result of getting the user's basic
            // information or getting the user's permissions.
            if ([result objectForKey:@"name"]) {
                // If basic information callback, set the UI objects to
                // display this.
                self.profileNameLabel.text = [result objectForKey:@"name"];
                // Get the pr

...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...