From ba787a1adbf9a5fedf2139c5b950485fe47f107a Mon Sep 17 00:00:00 2001 From: Sencerd Date: Tue, 2 Oct 2018 11:54:04 -0700 Subject: [PATCH] Fix code attempting to set an enum to null CardCategory cannot be null, so change the default value to NO_CATEGORY, and only add it to Categories if it is the only category in the JSON array --- Assets/Plugins/Appboy/models/Cards/Card.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/Appboy/models/Cards/Card.cs b/Assets/Plugins/Appboy/models/Cards/Card.cs index 6ccaaa705..6b3dfa6ee 100755 --- a/Assets/Plugins/Appboy/models/Cards/Card.cs +++ b/Assets/Plugins/Appboy/models/Cards/Card.cs @@ -47,11 +47,14 @@ public Card(JSONClass json) { Categories.Add(CardCategory.NO_CATEGORY); } else { for (int i = 0; i < jsonArray.Count; i++) { - CardCategory category = (CardCategory)EnumUtils.TryParse(typeof(CardCategory), jsonArray[i], true, null); - if (category != null) { + CardCategory category = (CardCategory)EnumUtils.TryParse(typeof(CardCategory), jsonArray[i], true, CardCategory.NO_CATEGORY); + if (category != CardCategory.NO_CATEGORY) { Categories.Add(category); } } + if (Categories.Count == 0) { + Categories.Add(CardCategory.NO_CATEGORY); + } } }