Skip to content

Commit

Permalink
this probably makes more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
langleyd committed May 18, 2023
1 parent e1c9e5a commit 3287d5c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary

NSArray<MXEvent*> *chunk;
NSArray *chunkJson = JSONDictionary[@"chunk"];
MXJSONModelSetMXJSONModelArray(chunk, MXEvent.class, chunkJson)

// For some reason modelsFromJSON returns nil if you pass it an empty array.
// In this case we want an empty array or we get an error.
if(!chunk && [chunkJson isKindOfClass:NSArray.class])
if([chunkJson isKindOfClass:NSArray.class] && chunkJson.count == 0)
{
chunk = @[];
} else {
MXJSONModelSetMXJSONModelArray(chunk, MXEvent.class, chunkJson)
}

if (chunk)
Expand Down

0 comments on commit 3287d5c

Please sign in to comment.