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

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

问题描述

以前,在iPhone OS 3.2与XCode 3.2.2这以前工作正常。



我创建了一个小测试来证明它。一个NSManagedObject有2个属性,group和vaue。两个字符串。



当设置一个NSFetchedResultsController在TableViewController中使用时,我在请求上设置setFetchLimit,并将sectionNameKeyPath设置为group,因为我



之前的行为(以前的iPhone OS 4和XCode 3.2.3)将返回包含最大数量的结果实体的结果集



对于新的OS和XCode,每个部分中的FecthedResultsControllersections和numberOfObjects返回持久存储中的所有值,忽略



但是当委托方法尝试访问数据时,它不在那里,它会生成一个
[_PFBatchFaultingArray objectAtIndex:]:index X)超出边界(X)',X是我设置的限制,并导致应用程序崩溃。



在我看来,SDK中有一个错误



问题的一个例子:


$在包含3项的数据存储组A,包含2项的组B和包含2项(为项7的总数)的组C中具有的b $ b <并将limit设置为7,则将返回所有节。



其他人遇到这个问题?

解决方案

使用单个部分崩溃。解决方案是马特的建议和大卫的答复的混合体;我把cacheName设置为nil:

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


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

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

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.

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.

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.

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.

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.

An example of the problem:

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?

解决方案

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天全站免登陆