Sheikh Muhammad Amaan-Ullah Sheikh Muhammad Amaan-Ullah - 1 month ago 10
iOS Question

How to concatenate NSURL in Objective-c .?

I have a NSURL named url where i Have an api that is calling some movie names. the problem is I want to enter user defined values in it :O
I have UIsearchBar for text input.

NSURL *url=[NSURL URLWithString:@"https://api.themoviedb.org/3/search/movie?query=""&api_key=c4bd8170"];

Answer
NSString *movieName;    //String from UISearchBar
NSString *movieString = [NSString stringWithFormat:@"https://api.themoviedb.org/3/search/movie?query=%@&api_key=c4bd8170",movieName];
NSURL *url=[NSURL URLWithString:movieString];