I'm building my app with TheMovieDB API but my JSONObject always is nil.I don't know what I'm doing wrong.This is my code:
@implementation SKTMovieLibrary
-(id) init{
if (self = [super init]) {
NSURL *url = [NSURL URLWithString:@"https://api.themoviedb.org/3/movie/now_playing?api_key=myApiKey"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *err){
NSDictionary * movieDict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSArray *JSONArray = [movieDict objectForKey:@"results"];
dispatch_async(dispatch_get_main_queue(), ^{
_JSONObject = JSONArray;
});
}];
[dataTask resume];
Thanks.