-1

我正在尝试创建一个 iOS 应用程序,该应用程序具有一个从网站(使用 JSON)获取信息并将信息存储在 CoreData 上的集合视图。

我在 CoreData 上有 2 个实体。1 称为区域(将是集合标题文本)。1 称为分销商(将是收集单元)。

要使用 CollectionView + CoreData 我看过这个例子:https ://github.com/AshFurrow/UICollectionViewExample

我设置了一切并正常工作,但有时,当我多次旋转设备并且集合视图仍然滚动时,我会看到此错误:

*** 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)

我已经创建了一个演示应用程序,准备好启动它并检查错误,你可以在这里下载它:https ://www.dropbox.com/s/cg86896ld6240r5/CollectionTest.zip

如果有人知道可能是什么问题,我将不胜感激。

提前致谢。

4

2 回答 2

2

我认为这与 CoreData 无关。我认为这与 iOS 7 中与 doURLificationOnDocument 相关的错误有关。我们在我们的应用程序中遇到了同样的问题,它没有使用任何核心数据。如果您查看此堆栈溢出链接:iOS 7 UITextView link detection crash in UITableView,您会看到其他人在抱怨同样的问题。

于 2014-02-27T21:36:52.337 回答
0

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.

于 2014-02-20T17:18:56.893 回答