I am using Obj-c and I can get the actor brad pitt but trying to get his id has been a little more challenging.
Here is the query I am using: https://api.themoviedb.org/3/search/person?query=Brad+Pitt&api_key=xxxxxxxxxxx
This is the JSON object I have of Brad Pitt: { page = 1; results = (
{ adult = 0; id = 287; name = "Brad Pitt"; popularity = "7.84036921219752"; "profilepath" = "/kc3M04QQAuZ9woUvH3Ju5T7ZqG5.jpg"; } ); "totalpages" = 1; "total_results" = 1; }
Then I do:
NSDictionary *results = [json objectForKey:@"results"]; //have also tried NSArray and wouldn't it crashed.
This is what it displays:
{ adult = 0; id = 287; name = "Brad Pitt"; popularity = "7.84036921219752"; "profile_path" = "/kc3M04QQAuZ9woUvH3Ju5T7ZqG5.jpg"; }
My question is how do I extract that id number? Thank you again in advance
Nevari atrast filmu vai TV pārraidi? Jāpiesakās, lai to izveidotu.
Vēlies novērtēt šo vienumu vai pievienot to sarakstam?
Neesi dalībnieks?
Atbilde no Joey Richardson
on jūlijs 29, 2014 at 8:45 PM
Got it what happens is results is an array containing one object in the [0] index which itself is an NSDictionary so you need to get the first index then call object for key.
Atbilde no marcelosampaio
on jūlijs 30, 2014 at 5:35 PM
Simple Sample: