NSFetchedResultsController - id <nsfetchedresultssectioninfo> sectionInfo - [sectionInfo numberOfObjects]是1,带有两个对象

时间:2015-07-28 01:08:11

标签: ios core-data nsfetchedresultscontroller

我正在使用这种常用方法来获取<form> <div class = 'form-group'> <%= form_tag '/signup', method: 'post', :class => 'form-inline' do %> <%= label_tag "Username"%> <%= text_field_tag :user_name, class: 'form-control' %> <br> <br> <%=label_tag "Password" %> <%= password_field_tag :password, class: 'form-control' %> <br> <br> <%=label_tag "Retype Password" %> <%=password_field_tag :password_confirmation, class: 'form-control' %> <br> <br> <%= submit_tag "Join!", class: 'btn btn-default btn-lg btn-submit' %> <%= link_to "Cancel" , '/login', class: 'btn btn-default btn-lg'%> </div> <%end%> </form> 部分中的对象数量:

NSFetchedResultsController

似乎是一个人。我知道它是1而不是0,因此对于三个对象,它应该返回3。

当有3个对象时,

id<NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsControllerCourse sections] objectAtIndex:indexPath.section]; NSInteger sectionInfoCount = [sectionInfo numberOfObjects]; 。 当有2个对象时sectionInfoCount = 2。 当有1个对象时sectionInfoCount = 1

当有2个OR 1对象时,为什么sectionInfoCount = 1等于1,当有3个对象时,为{2}? (3,当有4个等时......)

在转换为int时也会发生这种情况。 (我认为这可能是一个NSInteger包装问题)

1 个答案:

答案 0 :(得分:0)

SectionInfo.numberOfObjects将返回&#34; count&#34;,类似于数组的count。所以你的假设是不正确的。 (<Section info count>, <actual number of objects>) 始终 (n,n)

检查存储在持久存储中的数据,提取的结果控制器设置,尤其是排序和sectionNameKeyPath,并验证这是否一致。