gpt4 book ai didi

iphone - 如何获取适用于 iOS 的 Facebook 相册?

转载 作者:可可西里 更新时间:2023-11-01 04:44:36 24 4
gpt4 key购买 nike

我向 Facebook 提出以下简单请求。我的目标是获取用户所有相册的名称:

[[AppDelegate sharedDelegate].facebook requestWithGraphPath:@"me/albums" andDelegate:[AppDelegate sharedDelegate]];

然后,我从服务器得到一个 JSON 响应,如下所示:

data =     (
{
"can_upload" = 1;
count = 4;
"cover_photo" = 321491374598618;
"created_time" = "2012-06-04T21:46:23+0000";
from = {
id = 100002132746588;
name = "Owner....";
};
id = 321491371265285;
link = "http://www.facebook.com/album.php?fbid=321491371265285&id=100002132746588&aid=73680";
name = "Photos";
privacy = custom;
type = normal;
"updated_time" = "2012-06-04T22:08:39+0000";
},
{
"can_upload" = 0;
count = 1;
"cover_photo" = 318401854907570;
"created_time" = "2012-05-31T00:00:35+0000";
description = "Which Friend Stalks You the Most?";
from = {
id = 100002132746588;
name = "Owner....";
};
id = 318401848240904;
link = "http://www.facebook.com/album.php?fbid=318401848240904&id=100002132746588&aid=73163";
name = "Which Friend Stalks You the Most?";
privacy = friends;
type = normal;
"updated_time" = "2012-05-31T00:00:36+0000";
},

等等。问题是,当我尝试使用以下方法解析数据时:

NSLog(@"%@", [result objectForKey:@"name"]);

我得到 null。我假设发生这种情况是因为返回数据的 NSDictionary 不知道要关注哪个 name 条目。如何解析数据以便获得所有相册的名称?

最佳答案

“result”实际上是一个字典数组,因此遍历数组然后从数组中的每个元素中获取名称。

for (NSDictionary *anAlbum in [result objectForKey:@"data"]) {
NSLog(@"%@", [anAlbum objectForKey:@"name"]);
}

关于iphone - 如何获取适用于 iOS 的 Facebook 相册?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10889375/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com