From dcf562fb26264b0bc10796a281faeb41352eb9b7 Mon Sep 17 00:00:00 2001 From: John Estropia Date: Thu, 9 Jun 2016 17:57:15 +0900 Subject: [PATCH] ignore negative indexes when using ListMonitor's safeIndex API --- Sources/Observing/ListMonitor.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/Observing/ListMonitor.swift b/Sources/Observing/ListMonitor.swift index a3d38da..e76a18e 100644 --- a/Sources/Observing/ListMonitor.swift +++ b/Sources/Observing/ListMonitor.swift @@ -121,13 +121,15 @@ public final class ListMonitor: Hashable { !self.isPendingRefetch || NSThread.isMainThread(), "Attempted to access a \(cs_typeName(self)) outside the main thread while a refetch is in progress." ) - + guard sectionIndex >= 0 && itemIndex >= 0 else { + + return nil + } guard let sections = self.fetchedResultsController.sections where sectionIndex < sections.count else { return nil } - let section = sections[sectionIndex] guard itemIndex < section.numberOfObjects else {