简体   繁体   中英

Multiple requestWithGraphPath Facebook iOS

Maybe a simple question but I can't seem to get it. I want to get the users profile picture but also want search his/her posts. Like this:

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

I can get the picute out 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 don't know how i can get the search query data out.

Any help would be great! Thnx

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


For example, you can have two properties to hold the request objects. Although, if you are going to deal with many requests, you can use a container like NSDictionary instead.

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

And then in request:didLoad: :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM