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

- (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);
      }];

}

Open in new window


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;
    };
}

Open in new window


i need title and video id to saved in array or dictionary, any sample code would be of a great help.
syeudddAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KRUNAL TAILORFreelance Mobile DeveloperCommented:
Hi syeuddd,

you may try something like below code which i modified. But you may refactor this code based on your requirement.
You can create one dictionary to manage id and title.

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);
          NSArray *responceArr = [self.youtubePosts objectForKey:@"items"];
          NSMutableArray *titleArray = [[NSMutableArray alloc] init];
          NSMutableArray *idArray = [[NSMutableArray alloc] init];
 
          for(int i=0; i<responceArr.count ; i++)
          {
              NSDictionary *dict = [responceArr objectAtIndex:i];
              NSLog(@"%@:%@",[[dict objectForKey:@"snippet"] objectForKey:@"title"],[dict objectForKey:@"id"]);

              [titleArray addObject:[[dict objectForKey:@"snippet"] objectForKey:@"title"]];
              [idArray addObject:[dict objectForKey:@"id"]];
          }
          
          NSLog(@"%@",titleArray);
          NSLog(@"%@",idArray);
          
      } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          NSLog(@"Error: %@", error);
      }];

Open in new window


Hope this what you are looking.

Thanks & Regards,
Krunal T. Tailor
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
iPhone

From novice to tech pro — start learning today.