From 4e61b461b535dfd6363974ac1b536efba52869d0 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 18 Sep 2015 12:40:46 +0200 Subject: [PATCH] Use NSJSONSerialization --- MP42/MP42Ratings.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/MP42/MP42Ratings.m b/MP42/MP42Ratings.m index 56ed5df..31288e4 100644 --- a/MP42/MP42Ratings.m +++ b/MP42/MP42Ratings.m @@ -8,8 +8,6 @@ #import "MP42Ratings.h" -#import "JSONKit.h" - @implementation MP42Ratings @synthesize ratings; @@ -30,8 +28,13 @@ return nil; } - JSONDecoder *jsonDecoder = [JSONDecoder decoder]; - ratingsDictionary = [[jsonDecoder objectWithData:[NSData dataWithContentsOfFile:ratingsJSON]] retain]; + NSData *data = [NSData dataWithContentsOfFile:ratingsJSON]; + + if (data) { + ratingsDictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil]; + } else { + ratingsDictionary = [[NSMutableArray alloc] init]; + } // construct movie ratings ratings = [[NSMutableArray alloc] init];