iPhone OS4 (XCode 3.2.3) 上的 setFetchLimit 和 sectionNameKeyPath 导致崩溃 [英] setFetchLimit and sectionNameKeyPath on iPhone OS4 (XCode 3.2.3) cause crash

查看:21
本文介绍了iPhone OS4 (XCode 3.2.3) 上的 setFetchLimit 和 sectionNameKeyPath 导致崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前,在带有 XCode 3.2.2 的 iPhone OS 3.2 上,这曾经可以正常工作.

Previously, on iPhone OS 3.2 with XCode 3.2.2 this used to work fine.

我创建了一个小测试来证明这一点.一个具有 2 个属性的 NSManagedObject,group"和vaue".两个字符串.

I have created a small test to prove it. An NSManagedObject with 2 attributes, "group" and "vaue". Both strings.

在设置要在 TableViewController 中使用的 NSFetchedResultsController 时,我在请求中设置了 setFetchLimit,并将 sectionNameKeyPath 设置为组",因为我希望将结果实体分组到部分中.

When setting up an NSFetchedResultsController to be used in the TableViewController, I set up the setFetchLimit on the request and I set the sectionNameKeyPath to "group", since I want the result entities to be grouped in sections.

前一种行为(iPhone OS 4 和 XCode 3.2.3 之前的版本)将返回包含限制中指定的最大实体数量的实体的结果集.

The former behaviour (prior iPhone OS 4 and XCode 3.2.3) would return the resultset of entites containing the maximum amount of entities specified in the limit.

使用新的操作系统和 XCode,每个部分中的 FecthedResultsControllersections"和 numberOfObjects 返回持久存储中的所有值,忽略设置的限制.

With the new OS and XCode, the FecthedResultsController "sections" and numberOfObjects in each section return ALL the values that are in the persistent store, ignoring the set Limit.

但是当委托方法尝试访问数据时,它并不存在,它会生成一个[_PFBatchFaultingArray objectAtIndex:]: index (X) beyond bounds (X)',是我设置的限制X,导致应用崩溃.

But when the delegate methods try to access the data, it's not there, and it generates a [_PFBatchFaultingArray objectAtIndex:]: index (X) beyond bounds (X)', being X the limit I set, and causing the application to crash.

在我看来,SDK 中在使用自 3.2.3/OS 4 以来引入的限制和部分时存在错误.

It seems to me that there is a bug in the SDK when using the limits and the sections together that has been introduced since 3.2.3/OS 4.

问题的一个例子:

在数据存储组A"中包含3"个项目,组B"包含2"个项目和组C"包含2"个项目(即项目总数 7),以及限制设置为 7,将返回所有部分.如果限制设置为小于 7,应用程序将崩溃.

having in the data store group "A" containing "3" items, group "B" containing "2" items and group "C" containing "2" items (being the total number of items 7), and the limit is set to 7, all the sections will be returned. If the limit is set to less than 7, the application will crash.

还有其他人遇到这个问题吗?

Anyone else is experiencing this issue?

推荐答案

单节崩溃.解决方案是马特的建议和大卫的回答的混合体;我将 cacheName 设置为 nil:

Was crashing with a single section. Solution is a hybrid of Matt's suggestion and David's reply; I set the cacheName to nil in:

- (id)initWithFetchRequest:managedObjectContext:sectionNameKeyPath:**strong text**cacheName:**strong text**

这篇关于iPhone OS4 (XCode 3.2.3) 上的 setFetchLimit 和 sectionNameKeyPath 导致崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆