Facebook-iOs-API 如何在自定义函数中获取响应
如何捕获自定义函数中的响应?基本上答案是:
- (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";
}
}
}
但是我需要另一个函数,因为在这个函数中仅使用很少的模式不可能(或太难)获得我需要的所有响应。
How to catch response in custom function? Basically answer gets:
- (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";
}
}
}
But i need to have another function because its impossible(or too hard) to get all responses that i need, using only few patterns in this function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在此处的示例应用程序中使用与 facebook 开发人员相同的架构
https://github.com/facebook/wishlist-mobile-sample/blob/master/iOS/Wishlist/Wishlist/HomeViewController.m
他们创建 currentAPIcall 变量并根据请求填充它,如下所示:
...
you can use same schema as facebook developers in their sample application here
https://github.com/facebook/wishlist-mobile-sample/blob/master/iOS/Wishlist/Wishlist/HomeViewController.m
they create currentAPIcall variable and fill it depending on request like that:
...