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];
开发者_Python百科 [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) {
// ...
}
}
精彩评论