NSFetchedResultsController: Vários FRCs, delegam erro ao atualizar
Objetivo: Usando FRC, classifiqueSection's
porstartDate
, aNSDate
atributo, mas querToday
data deSection
aparecer antesUpcoming
datasSection
.
Eu segui o código da Apple usando uma propriedade transitóriasectionIdentifier
. Código de exemplo da Apple. e começou com este projeto primeiro:OneFRC
Logo percebi que isso pode não ser possível com apenas um FRC (eu posso estar errado).
Em seguida, decidi dar uma facada nisso com 3 FRCs: ThreeFRC.
Vista de mesasections
agora aparece na ordem que eu quero:
Seção 0:Today
Seção 1:Upcoming
Seção 2:Past
No entanto, adicionar dados aciona delegados FRC e recebo o seguinte erro:
CoreData: error: Serious application error. An exception was caught from the
delegate of NSFetchedResultsController during a call to
-controllerDidChangeContent:. Invalid update: invalid number of rows in section 0.
The number of rows contained in an existing section after the update (4) must be
equal to the number of rows contained in that section before the update (3), plus
or minus the number of rows inserted or deleted from that section (0 inserted,
0 deleted) and plus or minus the number of rows moved into or out of that section
(0 moved in, 0 moved out). with userInfo (null)
Mais uma vez, eu gostaria de poder realizar meu objetivo com 1 FRC, mas não consigo descobrir como.
Estou tentando resolver isso há 4 dias! Se esse problema não for resolvido no SO, acho que posso entrar em contato com o suporte da Apple para desenvolvedor. E, se eu fizer, postarei a resolução aqui para que outros possam se beneficiar.
Os projetos estão disponíveis no Github:
EDITAR
Graças a @blazejmar, consegui me livrar dorows
erro. No entanto, agora recebo um erro ao tentar adicionarsections
.
2014-11-03 16:39:46.852 FRC[64305:60b] CoreData: error: Serious application error.
An exception was caught from the delegate of NSFetchedResultsController during a
call to -controllerDidChangeContent:. Invalid update: invalid number of sections.
The number of sections contained in the table view after the update (2) must be
equal to the number of sections contained in the table view before the update (1),
plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).
with userInfo (null)
Etapas para reproduzir o erro no Three FRC:
1. Launch App ->
2. Tap Generate Data ->
3. Tap View in FRC ->
4. Tap back to the RootVC ->
5. Change the system date to a month from Today ->
6. Tap View in FRC and only one section `Past` should appear. ->
7. Tap `Add Data`.
8. The error should appear in the log.