syeuddd
asked on
Need help parsing youtube API data through AFnetworking, IOS
I'm trying to parse youtube API JSON data through afnetworking, i'am able to fetch the data however unable to parse it to create data model, I'm fairly new to objective c sample code would be a great help
following is the result of the response object.
i need title and video id to saved in array or dictionary, any sample code would be of a great help.
- (void)viewDidLoad {
[super viewDidLoad];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=LL-RGHu33yqGizdUpYcpzNQg&key=AIzaSyDSNtnNbv1PNxcbxnn7dF4EhR2Y_im7aiQ"
parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.youtubePosts = (NSDictionary *)responseObject;
NSLog(@"%@",self.youtubePosts);
//NSLog(@"the title is %@", [self.youtubePostsNested objectForKey:@"title"]);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
following is the result of the response object.
2015-05-01 03:49:36.572 youtubeApi[62960:2424144] {
etag = "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/otIE0jmUFTmh8nN3AC5v9-qutSg\"";
items = (
{
etag = "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/GJwAmpkpXMtuExNorueFICDEV3M\"";
id = "LLQ6oMtuoYncJPp04sgtK3W2_jJrYt0zEo";
kind = "youtube#playlistItem";
snippet = {
channelId = "UC-RGHu33yqGizdUpYcpzNQg";
channelTitle = "Mohamed Masloh";
description = "Join and Follow us on :\nYouTube : http://www.youtube.com/cbcegypt\nFacebook : http://www.facebook.com/cbcegypt\nGoogle+: http://www.gplus.to/cbcegypt\nTwitter : http://www.twitter.com/cbc_egy\n#CBCEgy - #Momken - #\U0645\U0645\U0643\U0646\nCBC - \U0645\U0645\U0643\U0646 - \U062e\U064a\U0631\U064a \U0631\U0645\U0636\U0627\U0646 -- 23-8-2013#\n \U0645\U0645\U0643\U0646 - 23-8-2013 - \U0627\U0644\U062d\U0648\U0627\U0631 \U0627\U0644\U0643\U0627\U0645\U0644 \U0644\U0644\U0634\U064a\U062e \U0639\U0644\U064a \U062c\U0645\U0639\U0647 \U0645\U0639 \U062e\U064a\U0631\U064a \U0631\U0645\U0636\U0627\U0646#\n\U0636\U064a\U0641 \U0627\U0644\U062d\U0644\U0642\U0629\n\U0639\U0644\U0649 \U062c\U0645\U0639\U0647 - \U0645\U0641\U062a\U0649 \U0627\U0644\U062f\U064a\U0627\U0631 \U0627\U0644\U0645\U0635\U0631\U064a\U0629 \U0627\U0644\U0633\U0627\U0628\U0642";
playlistId = "LL-RGHu33yqGizdUpYcpzNQg";
position = 0;
publishedAt = "2013-08-24T01:27:51.000Z";
resourceId = {
kind = "youtube#video";
videoId = DcAoD8FttnU;
};
thumbnails = {
default = {
height = 90;
url = "https://i.ytimg.com/vi/DcAoD8FttnU/default.jpg";
width = 120;
};
high = {
height = 360;
url = "https://i.ytimg.com/vi/DcAoD8FttnU/hqdefault.jpg";
width = 480;
};
medium = {
height = 180;
url = "https://i.ytimg.com/vi/DcAoD8FttnU/mqdefault.jpg";
width = 320;
};
standard = {
height = 480;
url = "https://i.ytimg.com/vi/DcAoD8FttnU/sddefault.jpg";
width = 640;
};
};
title = "#Momken - \U0645\U0645\U0643\U0646 - 23-8-2013 - \U0627\U0644\U062d\U0648\U0627\U0631 \U0627\U0644\U0643\U0627\U0645\U0644 \U0644\U0644\U0634\U064a\U062e \U0639\U0644\U064a \U062c\U0645\U0639\U0647 \U0645\U0639 \U062e\U064a\U0631\U064a \U0631\U0645\U0636\U0627\U0646#";
};
},
{
etag = "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/_LFzVe3wmWWAFIdOGsU3Icel6LU\"";
id = "LLQ6oMtuoYncJP_Jg7o3yuH-c7Ked_zgjZ";
kind = "youtube#playlistItem";
snippet = {
channelId = "UC-RGHu33yqGizdUpYcpzNQg";
channelTitle = "Mohamed Masloh";
description = "\U0627\U0644\U0634\U064a\U062e \U0639\U0644\U064a \U062c\U0645\U0639\U0629 \U064a\U0648\U0636\U062d \U0645\U0639\U0646\U0649 \U0627\U0644\U0628\U062f\U0639\U0629";
playlistId = "LL-RGHu33yqGizdUpYcpzNQg";
position = 1;
publishedAt = "1970-01-01T00:00:00.000Z";
resourceId = {
kind = "youtube#video";
videoId = ad8yCe8SQrY;
};
thumbnails = {
default = {
height = 90;
url = "https://i.ytimg.com/vi/ad8yCe8SQrY/default.jpg";
width = 120;
};
high = {
height = 360;
url = "https://i.ytimg.com/vi/ad8yCe8SQrY/hqdefault.jpg";
width = 480;
};
medium = {
height = 180;
url = "https://i.ytimg.com/vi/ad8yCe8SQrY/mqdefault.jpg";
width = 320;
};
};
title = "\U0627\U0644\U0634\U064a\U062e \U0639\U0644\U064a \U062c\U0645\U0639\U0629 \U064a\U0648\U0636\U062d \U0645\U0639\U0646\U0649 \U0627\U0644\U0628\U062f\U0639\U0629";
};
},
{
etag = "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/ZjQAl2CPf22-SIC-bdjUY8EjNYI\"";
id = "LLQ6oMtuoYncJcZVKRzNtgmhjFZs_LLWzE";
kind = "youtube#playlistItem";
snippet = {
channelId = "UC-RGHu33yqGizdUpYcpzNQg";
channelTitle = "Mohamed Masloh";
description = "";
playlistId = "LL-RGHu33yqGizdUpYcpzNQg";
position = 2;
publishedAt = "2015-04-26T07:29:07.000Z";
resourceId = {
kind = "youtube#video";
videoId = xBoR2E2Vj6E;
};
thumbnails = {
default = {
height = 90;
url = "https://i.ytimg.com/vi/xBoR2E2Vj6E/default.jpg";
width = 120;
};
high = {
height = 360;
url = "https://i.ytimg.com/vi/xBoR2E2Vj6E/hqdefault.jpg";
width = 480;
};
medium = {
height = 180;
url = "https://i.ytimg.com/vi/xBoR2E2Vj6E/mqdefault.jpg";
width = 320;
};
};
title = "\U062d\U0628\U064a\U0628 \U062d\U0628\U064a\U0628\U064a \U062d\U0628\U064a\U0628\U064a, \U0645\U062d\U0645\U062f \U0645\U0635\U0644\U0648\U062d";
};
},
{
etag = "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/JoNOJoCBdJuA-MW6R5ueJH1cGbY\"";
id = "LLQ6oMtuoYncKaDL5Jd-BKs4pf-faM7Gm5";
kind = "youtube#playlistItem";
snippet = {
channelId = "UC-RGHu33yqGizdUpYcpzNQg";
channelTitle = "Mohamed Masloh";
description = "";
playlistId = "LL-RGHu33yqGizdUpYcpzNQg";
position = 3;
publishedAt = "2015-04-25T14:01:53.000Z";
resourceId = {
kind = "youtube#video";
videoId = SirSwiorKv4;
};
thumbnails = {
default = {
height = 90;
url = "https://i.ytimg.com/vi/SirSwiorKv4/default.jpg";
width = 120;
};
high = {
height = 360;
url = "https://i.ytimg.com/vi/SirSwiorKv4/hqdefault.jpg";
width = 480;
};
maxres = {
height = 720;
url = "https://i.ytimg.com/vi/SirSwiorKv4/maxresdefault.jpg";
width = 1280;
};
medium = {
height = 180;
url = "https://i.ytimg.com/vi/SirSwiorKv4/mqdefault.jpg";
width = 320;
};
standard = {
height = 480;
url = "https://i.ytimg.com/vi/SirSwiorKv4/sddefault.jpg";
width = 640;
};
};
title = "Treat people according to their Status, Mohamed Masloh 1";
};
},
{
etag = "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/ivWTpdnGqPNWJNnhreH-BZzhKqU\"";
id = "LLQ6oMtuoYncJ8FU6R2XHJu-L-kXFV5zCh";
kind = "youtube#playlistItem";
snippet = {
channelId = "UC-RGHu33yqGizdUpYcpzNQg";
channelTitle = "Mohamed Masloh";
description = "Everyone will be tested, a beautiful reminder from brother Majed Mahmoud about how we cant attain Jannah without going through some hardships and tests in this life..";
playlistId = "LL-RGHu33yqGizdUpYcpzNQg";
position = 4;
publishedAt = "2014-08-17T15:00:08.000Z";
resourceId = {
kind = "youtube#video";
videoId = JnZAlFkwkJo;
};
thumbnails = {
default = {
height = 90;
url = "https://i.ytimg.com/vi/JnZAlFkwkJo/default.jpg";
width = 120;
};
high = {
height = 360;
url = "https://i.ytimg.com/vi/JnZAlFkwkJo/hqdefault.jpg";
width = 480;
};
maxres = {
height = 720;
url = "https://i.ytimg.com/vi/JnZAlFkwkJo/maxresdefault.jpg";
width = 1280;
};
medium = {
height = 180;
url = "https://i.ytimg.com/vi/JnZAlFkwkJo/mqdefault.jpg";
width = 320;
};
standard = {
height = 480;
url = "https://i.ytimg.com/vi/JnZAlFkwkJo/sddefault.jpg";
width = 640;
};
};
title = "Everyone Will Be Tested \U1d34\U1d30 | Majed Mahmoud";
};
}
);
kind = "youtube#playlistItemListResponse";
nextPageToken = CAUQAA;
pageInfo = {
resultsPerPage = 5;
totalResults = 30;
};
}
i need title and video id to saved in array or dictionary, any sample code would be of a great help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.