Multiple Requests WithGraphPath Facebook iOS

Maybe a simple question, but I can’t get it. I want to get a user profile picture, but also want to search for his / her posts. Like this:

[facebook requestWithGraphPath:@"me/picture?type=large" andDelegate:self];
[facebook requestWithGraphPath:@"me/home?q=TEST" andDelegate:self];

I can get picut with the following code:

- (void)request:(FBRequest*)request didLoad:(id)result{
    if ([result isKindOfClass:[NSData class]])
    {

        UIImage *image = [[UIImage alloc] initWithData:result];
        UIImageView *profilePicture = [[UIImageView alloc] initWithImage:image];
        [image release];
        profilePicture.frame = CGRectMake(20, 20, 80, 80);
        [self.view addSubview:profilePicture];
        [profilePicture release];

    }
}

But I do not know how I can get the search query data.

Any help would be great! Thnx

+5
source share
1 answer

requestWithGraphPath:andDelegate:returns a pointer to an object of type FBRequest. Save it and use it later to distinguish between requests in request:didLoad:, comparing it with the first parameter passed to this method.


, . , , , NSDictionary.

self.pictureRequest = [facebook requestWithGraphPath:@"me/picture?type=large" andDelegate:self];
self.homeRequest = [facebook requestWithGraphPath:@"me/home?q=TEST" andDelegate:self];

request:didLoad::

- (void)request:(FBRequest*)request didLoad:(id)result {
    if (request == self.homeRequest) {
        // ...
    } else if (request == self.pictureRequest) {
        // ...
    }
}
+14

All Articles