Skip to content

Commit

Permalink
Fix code attempting to set an enum to null
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sencerd authored Oct 2, 2018
1 parent ab1d6bb commit ba787a1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Assets/Plugins/Appboy/models/Cards/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit ba787a1

Please sign in to comment.