Skip to content

Commit

Permalink
Merge pull request #1 from Sencerd/fix-null-enum
Browse files Browse the repository at this point in the history
Fix code attempting to set an enum to null
  • Loading branch information
Sencerd authored Oct 2, 2018
2 parents ab1d6bb + ba787a1 commit 5cdc490
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 5cdc490

Please sign in to comment.