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
.לא מצאת סרט או סדרה? היכנס כדי ליצור אותם
?רוצה לדרג או להוסיף פריט אל רשימה
?לא חבר אתר
תגובה מאת Joey Richardson
ב-יולי 29, 2014 ב-8:45אחרי חצות יום
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.
תגובה מאת marcelosampaio
ב-יולי 30, 2014 ב-5:35אחרי חצות יום
Simple Sample: