NSFetchedResultsController - NSInvalidArgumentException

Good morning, I've developed an application where we download a JSON of objects and we store those information on a CoreData table. We've also created a Collection view used to show those information through a NSFetchedResultsController. Can someone helps me to understand the reason why I get this issue?

Thanks indeed

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x83f20 __exceptionPreprocess
1  libobjc.A.dylib                0x16018 objc_exception_throw
2  CoreFoundation                 0x1b6250 _NSArrayRaiseInsertNilException
3  CoreFoundation                 0x16f5c -[__NSCFArray objectAtIndex:]
4  CoreData                       0x13af14 -[_PFMutableProxyArray subarrayWithRange:]
5  CoreData                       0xc4948 -[_NSDefaultSectionInfo objects]
6  CoreData                       0x9c3fc -[NSFetchedResultsController _conditionallyDispatchSnapshotToDelegate:updatesInfo:]
7  CoreData                       0x6d4ec __82-[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:]_block_invoke
8  CoreData                       0x270dc developerSubmittedBlockToNSManagedObjectContextPerform
9  CoreData                       0x9d0ec -[NSManagedObjectContext performBlockAndWait:]
10 CoreData                       0x9c6e8 -[NSFetchedResultsController _core_managedObjectContextDidChange:]
11 CoreFoundation                 0x5178c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
12 CoreFoundation                 0x516a8 ___CFXRegistrationPost_block_invoke
13 CoreFoundation                 0x515f0 _CFXRegistrationPost
14 CoreFoundation                 0x4fbb8 _CFXNotificationPost
15 Foundation                     0x31574 -[NSNotificationCenter postNotificationName:object:userInfo:]
16 CoreData                       0x6a548 -[NSManagedObjectContext _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:]
17 CoreData                       0x69d10 -[NSManagedObjectContext _postRefreshedObjectsNotificationAndClearList]
18 CoreData                       0x68a4c -[NSManagedObjectContext _processRecentChanges:]
19 CoreData                       0x91494 -[NSManagedObjectContext _coreMergeChangesFromDidSaveDictionary:usingObjectIDs:withClientQueryGeneration:]
20 CoreData                       0x90334 -[NSManagedObjectContext mergeChangesFromContextDidSaveNotification:]
21 CoreData                       0x270dc developerSubmittedBlockToNSManagedObjectContextPerform
22 libdispatch.dylib              0x3dd4 _dispatch_client_callout
23 libdispatch.dylib              0x125a4 _dispatch_main_queue_drain
24 libdispatch.dylib              0x121b8 _dispatch_main_queue_callback_4CF
25 CoreFoundation                 0x56710 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
26 CoreFoundation                 0x53914 __CFRunLoopRun
27 CoreFoundation                 0x52cd8 CFRunLoopRunSpecific
28 GraphicsServices               0x11a8 GSEventRunModal
29 UIKitCore                      0x40a90c -[UIApplication _run]
30 UIKitCore                      0x4be9d0 UIApplicationMain
31 Rainbow                        0x80c0 main + 15 (main.swift:15)
32 ???                            0x1b3419e4c (Mancante)

What code is running at the time?

Taking a look, it seems there is a nil item in the array (or no items in the array)?

2  CoreFoundation                 0x1b6250 _NSArrayRaiseInsertNilException
3  CoreFoundation                 0x16f5c -[__NSCFArray objectAtIndex:]

I've created a Queue that is used to parse a JSON Array in chunks and store those information into Core Data.

Could be that the NSFetchedResultsController is trying to update the Snapshot when the Context is saving some changes?

NSFetchedResultsController - NSInvalidArgumentException
 
 
Q