Don't crash on invalid Lottie json

This commit is contained in:
Ilya Laktyushin 2019-09-11 08:01:49 +03:00
parent 5c94feb216
commit ae25ca6920

View File

@ -63,7 +63,7 @@
NSData *jsonData = [[NSData alloc] initWithContentsOfFile:filePath]; NSData *jsonData = [[NSData alloc] initWithContentsOfFile:filePath];
NSDictionary *JSONObject = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData NSDictionary *JSONObject = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData
options:0 error:&error] : nil; options:0 error:&error] : nil;
if (JSONObject && !error) { if (JSONObject && [JSONObject isKindOfClass:[NSDictionary class]] && !error) {
LOTComposition *laScene = [[self alloc] initWithJSON:JSONObject withAssetBundle:[NSBundle mainBundle]]; LOTComposition *laScene = [[self alloc] initWithJSON:JSONObject withAssetBundle:[NSBundle mainBundle]];
laScene.rootDirectory = [filePath stringByDeletingLastPathComponent]; laScene.rootDirectory = [filePath stringByDeletingLastPathComponent];
[[LOTAnimationCache sharedCache] addAnimation:laScene forKey:animationName]; [[LOTAnimationCache sharedCache] addAnimation:laScene forKey:animationName];