gpt4 book ai didi

iphone - 如何从给定字符串中获取数组中所有源 url 的值

转载 作者:行者123 更新时间:2023-11-28 19:17:03 24 4
gpt4 key购买 nike

{    data =     (                {            "created_time" = "2011-09-28T07:29:37+0000";            from =             {                id = 100002944043966;                name = "alok sinha";            };            height = 500;            icon = "https://s-static.ak.facebook.com/rsrc.php/v2/yz/r/StEh3RhPvjk.gif";            id = 114750595299741;            images =             (                                {                    height = 2048;                    source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s2048x2048/300035_114750595299741_1543248164_n.jpg";                    width = 2048;                },                                {                    height = 500;                    source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg";                    width = 500;                },                                {                    height = 500;                    source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg";                    width = 500;                },                                {                    height = 480;                    source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s480x480/300035_114750595299741_1543248164_n.jpg";                    width = 480;                },                                {                    height = 320;                    source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s320x320/300035_114750595299741_1543248164_n.jpg";                    width = 320;                },                                {                    height = 180;                    source = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_a.jpg";                    width = 180;                },                                {                    height = 130;                    source = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_s.jpg";                    width = 130;                },                                {                    height = 130;                    source = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/s75x225/300035_114750595299741_1543248164_s.jpg";                    width = 130;                }            );            link = "https://www.facebook.com/photo.php?fbid=114750595299741&set=a.114750591966408.20279.100002944043966&type=1";            picture = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_s.jpg";            position = 1;            source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg";            "updated_time" = "2011-09-28T07:29:38+0000";            width = 500;        }    );    paging =     {        next = "https://graph.facebook.com/114750591966408/photos?value=1&redirect=1&limit=25&after=MTE0NzUwNTk1Mjk5NzQx";    };}

最佳答案

NSArray *jsonArray; // your parsed array

NSDictionary *dict = [jsonArray objectAtIndex:0]; // there might be more of the objects and you might need to put that into a forin cycle, but for simplicity this is an example for an array with only one dictionary in it

NSArray *images = [dict objectForKey:@"images"];

NSMutableArray *links = [NSMutableArray array];

for (NSDictionary *img in images) {
[links addObject:[img valueForKey:@"source"]];
}

现在链接是您需要的 NSString 对象数组。如果需要,您还可以将它们转换为 NSURL。

关于iphone - 如何从给定字符串中获取数组中所有源 url 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11392298/

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