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からの返信
投稿:2014年07月29日 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.
marcelosampaioからの返信
投稿:2014年07月30日 5:35 PM
Simple Sample: