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 στις 08: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 στις 05:35 ΜΜ
Simple Sample: