Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:33:14+00:00 2026-06-11T22:33:14+00:00

I am working on an iPhone app with a UICollectionView, and am trying to

  • 0

I am working on an iPhone app with a UICollectionView, and am trying to create folders like the iPhones spring board. I have it working but am running into this error regarding the addition and subtraction of cells using core data. I was hoping someone could explain how I avoid this error? Thank You in advance.

* Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (4) must be equal to the number of items contained in that section before the update (3), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).’

——mainViewController

            //**Document One**
            //get first doc and create it as a sub doc
            Document * docToCopy = [[self birds] objectAtIndex:longPressFolderLayout.pinchedCellPath.row];
            SubDocument *doc = [[SubDocument alloc] initInsertingIntoManagedObjectContext:managedObjectContext];
            [doc setTitle:docToCopy.title];
            [doc setThumbnail:docToCopy.thumbnail];
            [doc setIsFolder:[NSNumber numberWithInt:0]];
            [doc setDate:docToCopy.date];


            //**Document Two**
            //get second doc and create it as a sub doc
            Document * docToCopy2 = [[self birds] objectAtIndex:cellAttributes.indexPath.row];
            SubDocument *doc2 = [[SubDocument alloc] initInsertingIntoManagedObjectContext:managedObjectContext];
            [doc2 setTitle:docToCopy2.title];
            [doc setThumbnail:docToCopy2.thumbnail];
            [doc2 setIsFolder:[NSNumber numberWithInt:0]];
            [doc2 setDate:docToCopy2.date];
            [self add:@"folder" image:[UIImage imageNamed:@"folderDefaultImage"] date:[NSDate date] folder:[NSNumber numberWithInt:1]];

            //**Folder**
            //create a folder and append both sub docs and then remove the original docs
            Document * origFolder = [[self birds] objectAtIndex:([[self birds]count]-1)];
            [origFolder appendDoc:doc];
            [origFolder appendDoc:doc2];
            [origFolder setIsFolder:[NSNumber numberWithInt:1]];
            currentOpenFolder = origFolder;
            [self removePageAtIndex:longPressFolderLayout.pinchedCellPath.row];
            [self removePageAtIndex:cellAttributes.indexPath.row];

——DocumentNSManagedObject

- (void)appendDoc:(SubDocument *)doc
{
[[self mutableSetValueForKey:@"subDocument"] addObject:doc];
[(NSMutableArray *)[self subDocumentsOrdered] addObject:doc];

    NSError *error = nil;
[[self managedObjectContext] save:&error];
}
- (void)deleteDoc:(SubDocument *)doc
{
    [[self mutableSetValueForKey:@"subDocument"] removeObject:doc];
    [(NSMutableArray *)[self subDocumentsOrdered]removeObject:doc];
    NSError *error = nil;
[[self managedObjectContext] save:&error];
}
- (NSArray *)subDocumentsOrdered
{
if (!subDocumentsOrdered)
{
subDocumentsOrdered = [[[[self subDocument] allObjects] sortedArrayWithOptions:NSSortStable|NSSortConcurrent usingComparator:(NSComparator) ^(SubDocument *stroke1, SubDocument *stroke2)
                          {
                              return [[stroke1 date] compare:[stroke2 date]];
                          }
                          ] mutableCopy];
}
    return subDocumentsOrdered;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:33:15+00:00Added an answer on June 11, 2026 at 10:33 pm

    I had a very similar problem recently in my app. If you look at where you are adding your pages I bet you are not saving them to the NSManagedObjectContext. A simple solution is just by writing:

    [[self managedObjectContext]save:nil];
    

    Hope this helps. Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an iPhone app and would like to have a simple text
I'm working on an iPhone app in which I'm trying to create a card
I am working on an iPhone app with Apple Push Notification integration. I have
I'm working on an iphone app and want to have a page showing multiple
I am working on an iPhone app, in which I have to enlist all
I am working on an iphone app in IOS5 that user storyboards. I have
I am working on an iPhone app where we are trying to calculate the
Greetings! I have a working iPhone app (huzzah!) that uses a MainView.xib containing a
I have been working with iPhone app as developer and now my PM(Project Manager)
I am working on an IPhone app and i have a UIWebview that by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.