Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8064381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:20:50+00:00 2026-06-05T11:20:50+00:00

From the facebook iOS API documentation, I’ve create two methods that request either the

  • 0

From the facebook iOS API documentation, I’ve create two methods that request either the friends list from the graph, or details about the currently logged in user.

- (IBAction)showMyFriends:(id)sender {
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [[delegate facebook] requestWithGraphPath:@"me/friends" andDelegate:self];
    NSLog(@"Getting friends list");
}
- (IBAction)showMyDetails:(id)sender {
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [[delegate facebook] requestWithGraphPath:@"me" andDelegate:self];
    NSLog(@"Getting my info");
}

Sounds reasonable so far. The delegate method that responds from these calls is :

- (void)request:(FBRequest *)request didLoad:(id)result
{
    NSLog(@"Got a request");

// Print out friends
//    NSArray * items = [NSArray alloc];
//    items = [(NSDictionary *)result objectForKey:@"data"];
//    for (int i=0; i<[items count]; i++) {
//        NSDictionary *friend = [items objectAtIndex:i];
//        long long fbid = [[friend objectForKey:@"id"]longLongValue];
//        NSString *name = [friend objectForKey:@"name"];
//        NSLog(@"id: %lld - Name: %@", fbid, name);
//    }


// Print out self username
    NSString *username = [result objectForKey:@"name"];
    NSLog(@"Username is %@", username);
    helloGreeting.text = [NSString stringWithFormat:@"Hello %@", username];

}

Question : In the didLoad, how can you check which graph request the current invocation relates to? For example, in the above code I would either want to print out the friends list, or print out the username, so I would image I need to wrap the code in some case/switch statement dependant on the request type.

I couldn’t find anything obvious on the API, what is the best approach for ensuring only relevant response code is executed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:20:52+00:00Added an answer on June 5, 2026 at 11:20 am

    Actually looks like Hackbook is doing a switch based on an int called “currentAPICall”, setting an int for each request, then checking on that in the return. So it’s all done in the main thread, I’m guessing.

    I also have different result objects, of different types. I end up looking at the result and determining if it’s from the /me request or from the /home. I have various “ifs” looking at the returning object. Not ideal by any means. I.e.

    if([result objectForKey:@"first_name"]){
        // back from getMe()
    }
    
    if ([result objectForKey:@"data"]) {
        // more checking here- I have two calls that return a data object
    }
    

    Update: this doesn’t work for asynchronous requests, and most of these are, so I used the method above, checking request.url, instead, and that works like a charm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm intending to create a flash app that pulls images from facebook and displays
In the documentation from facebook to integrate their sdk in iOS app, they mentioned
I'm having an issue with the Facebook graph API, and more precisely the iOS
I'm getting checkins from the facebook API in a iOS-app. This worked perfectly earlier,
I am using the latest Facebook SDK for iOS and Graph API. Works Great.
I need to share UIImage from my IOS application to Facebook, Twitter, Flicr, Picassa
I'm using the Facebook iOS SDK to post videos from my app to the
I have a strange issue trying to run the Facebook iOS SDK DemoApp (from
I downloaded the sample app from the latest facebook ios SDK. I set my
I start writing a simple app to use FaceBook IOS SDK from GitHub. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.