Skip to content

Commit 8b272b6

Browse files
author
Alexis Oyama
committed
fix(request): Added some minor protection for getResponseAt:
1 parent 8983211 commit 8b272b6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Leanplum-SDK/Classes/LeanplumRequest.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,10 @@ + (NSUInteger)numResponsesInDictionary:(NSDictionary *)dictionary
745745

746746
+ (NSDictionary *)getResponseAt:(NSUInteger)index fromDictionary:(NSDictionary *)dictionary
747747
{
748-
return [dictionary[@"response"] objectAtIndex:index];
748+
if (index < [LPResponse numResponsesInDictionary:dictionary]) {
749+
return [dictionary[@"response"] objectAtIndex:index];
750+
}
751+
return [dictionary[@"response"] lastObject];
749752
}
750753

751754
+ (NSDictionary *)getLastResponse:(NSDictionary *)dictionary

0 commit comments

Comments
 (0)