Question

I'm trying to create an iOS app which has a collectionview that takes information from a website (with JSON) and stores the info on CoreData.

I have 2 entities on CoreData. 1 Called Regions (wich will be the collection header texts). 1 Called Distributors (which will be the collection cells).

To use CollectionView + CoreData i have seen this example: https://github.com/AshFurrow/UICollectionViewExample

I set up everthing and works but sometimes, when i rotate the devide multiple times and the collection view still scrolls i see this error:

*** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'
*** First throw call stack:
(
    0   CoreFoundation                      0x01a9f5e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x015738b6 objc_exception_throw + 44
    2   CoreFoundation                      0x01a9f3bb +[NSException raise:format:] + 139
    3   Foundation                          0x011a5f62 -[NSRLEArray objectAtIndex:effectiveRange:] + 131
    4   Foundation                          0x011a7b86 -[NSConcreteMutableAttributedString addAttribute:value:range:] + 212
    5   UIFoundation                        0x034aab82 __50-[NSConcreteTextStorage addAttribute:value:range:]_block_invoke + 156
    6   UIFoundation                        0x034aaa65 -[NSConcreteTextStorage addAttribute:value:range:] + 127
    7   DataDetectorsUI                     0x0a7da85c -[DDTextKitOperation _addResultsToAttributes] + 374
    8   DataDetectorsUI                     0x0a7daa82 __46-[DDTextKitOperation doURLificationOnDocument]_block_invoke_2 + 39
    9   UIFoundation                        0x034a9190 -[NSTextStorage(ActorSupport) coordinateAccess:] + 48
    10  DataDetectorsUI                     0x0a7daa54 __46-[DDTextKitOperation doURLificationOnDocument]_block_invoke + 134
    11  libdispatch.dylib                   0x0222d440 _dispatch_barrier_sync_f_slow_invoke + 71
    12  libdispatch.dylib                   0x0223e4b0 _dispatch_client_callout + 14
    13  libdispatch.dylib                   0x0222c75e _dispatch_main_queue_callback_4CF + 340
    14  CoreFoundation                      0x01b04a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
    15  CoreFoundation                      0x01a456bb __CFRunLoopRun + 1963
    16  CoreFoundation                      0x01a44ac3 CFRunLoopRunSpecific + 467
    17  CoreFoundation                      0x01a448db CFRunLoopRunInMode + 123
    18  GraphicsServices                    0x03d569e2 GSEventRunModal + 192
    19  GraphicsServices                    0x03d56809 GSEventRun + 104
    20  UIKit                               0x002e1d3b UIApplicationMain + 1225
    21  CollectionTest                      0x0000934d main + 141
    22  libdyld.dylib                       0x024ce725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

I have created a demo app with everthing ready to launch it and check the error, you can download it here: https://www.dropbox.com/s/cg86896ld6240r5/CollectionTest.zip

I would appreciate any help if anyone know what could be the problem.

Thanks in advance.

No correct solution

OTHER TIPS

I don't think this has anything to do with CoreData. I think this has to do with a bug in iOS 7 related to doURLificationOnDocument. We're running into this same problem in our app that makes no use of core data whatsoever. If you look at this stack overflow link: iOS 7 UITextView link detection crash in UITableView, you'll see that someone else is complaining about the same problem.

You are not using Core Data properly. Your entities have no relationships to each other. Instead, you are relying on some kind of foreign key. This is not appropriate for object graphs such as Core Data and can lead to all kinds of unpredictable errors, including the one you are encountering.

Read up on how Core Data models work. Pay particular attention to the chapter Relationships and Fetched Properties in the Core Data Programming Guide.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top