【问题标题】:App crashes with NSRangeException _PFBatchFaultingArray using NSFetchedResultsController使用 NSFetchedResultsController 的应用程序因 NSRangeException _PFBatchFaultingArray 而崩溃
【发布时间】:2011-09-21 13:52:21
【问题描述】:

我收到了很多关于某个特定崩溃的崩溃报告,但不知道从哪里开始修复它,因为我自己无法重现它并且崩溃报告是匿名发送的。

如您所见,这与我正在使用的 NSFetchedResultsController 有关。

这是该崩溃报告的摘录。报告之间的唯一区别是索引[...]index (someLargeIndex) beyond bounds (1)[...] 的范围。其余的在每个报告中都保持不变。

Application Specific Information:
*** Terminating app due to uncaught exception \\\'NSRangeException\\\', reason: \\\'*** -[_PFBatchFaultingArray objectAtIndex:]: index (262144) beyond bounds (1)\\\'

Thread 0 Crashed:
0   libsystem_kernel.dylib              0x31d1e00c __kill + 8
1   libsystem_c.dylib                   0x32ac4f95 raise + 17
2   AppName                             0x0003d961 uncaught_exception_handler (PLCrashReporter.m:137)
3   CoreFoundation                      0x349b57d3 __handleUncaughtException + 239
4   libobjc.A.dylib                     0x33f9506b _objc_terminate + 103
5   libstdc++.6.dylib                   0x3338ae3d __cxxabiv1::__terminate(void (*)()) + 53
6   libstdc++.6.dylib                   0x3338ae91 std::terminate() + 17
7   libstdc++.6.dylib                   0x3338af61 __cxa_throw + 85
8   libobjc.A.dylib                     0x33f93c8b objc_exception_throw + 71
9   CoreFoundation                      0x349b5491 +[NSException raise:format:arguments:] + 69
10  CoreFoundation                      0x349b54cb +[NSException raise:format:] + 35
11  CoreData                            0x34820fc5 -[_PFBatchFaultingArray objectAtIndex:] + 133
12  CoreData                            0x3485e5fb -[_PFMutableProxyArray objectAtIndex:] + 55
13  CoreData                            0x348e00f7 +[NSFetchedResultsController(PrivateMethods) _insertIndexForObject:inArray:lowIdx:highIdx:sortDescriptors:] + 99
14  CoreData                            0x348e0605 -[NSFetchedResultsController(PrivateMethods) _postprocessInsertedObjects:] + 353
15  CoreData                            0x348e0ecf -[NSFetchedResultsController(PrivateMethods) _postprocessUpdatedObjects:] + 507
16  CoreData                            0x348e29c7 -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 1239
17  Foundation                          0x35f46183 _nsnote_callback + 143
18  CoreFoundation                      0x3498420f __CFXNotificationPost_old + 403
19  CoreFoundation                      0x3491eeeb _CFXNotificationPostNotification + 119
20  Foundation                          0x35f435d3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 71
21  CoreData                            0x34884c07 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 55
22  CoreData                            0x34884fcd -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 141
23  CoreData                            0x34845251 -[NSManagedObjectContext(_NSInternalChangeProcessing) _postRefreshedObjectsNotificationAndClearList] + 77
24  CoreData                            0x34844f7f -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1815
25  CoreData                            0x348863a5 -[NSManagedObjectContext processPendingChanges] + 17
26  CoreData                            0x3482027f _performRunLoopAction + 127
27  CoreFoundation                      0x3498ca35 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 17
28  CoreFoundation                      0x3498e465 __CFRunLoopDoObservers + 413
29  CoreFoundation                      0x3498f75b __CFRunLoopRun + 855
30  CoreFoundation                      0x3491fec3 CFRunLoopRunSpecific + 231
31  CoreFoundation                      0x3491fdcb CFRunLoopRunInMode + 59
32  GraphicsServices                    0x3354641f GSEventRunModal + 115
33  GraphicsServices                    0x335464cb GSEventRun + 63
34  UIKit                               0x3357dd69 -[UIApplication _run] + 405
35  UIKit                               0x3357b807 UIApplicationMain + 671
36  AppName                             0x00002b69 main (main.m:15)

很抱歉,我无法提供更多信息。任何建议如何开始?

【问题讨论】:

  • [_PFBatchFaultingArray objectAtIndex:]: index (262144) beyond bounds (1) 它与你的数组有关,访问数组 _PFBatchFaultingArray 的 262144 索引,它只有 2 个元素( bounds 1 )。我想说看看你的崩溃报告的其他线程。
  • 你想明白了吗?我在任何地方都找不到答案

标签: objective-c ios cocoa-touch core-data


【解决方案1】:

这可能是 NSFetchedResultsController 的缓存问题。多看这个问题:_PFBatchFaultingArray objectAtIndex:

【讨论】:

    【解决方案2】:

    尝试查看 cellForRowAtIndexPath: 或使用 NSFetchedResultsController 的结果的任何位置。在那里,使用以下代码查看有多少结果可供您使用:

    NSArray *sections = fetchController.sections;
    int someSection = 0;
    id <NSFetchedResultsSectionInfo> sectionInfo = [sections objectAtIndex:someSection];
    numberOfObjects = [sectionInfo numberOfObjects];
    

    然后去你试图获取信息的地方,可能是你打电话的地方:

    [fetchedResultsController objectAtIndexPath:indexPath];
    

    看看你忽略了什么:

    NSLog(@"row to be retrieved: %d", indexPath.row);
    [fetchedResultsController objectAtIndexPath:indexPath]; //here comes the crash
    

    最后,你可以检查

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    

    查看返回的行数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 2019-12-26
      • 2012-05-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多