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 6542925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:17:06+00:00 2026-05-25T11:17:06+00:00

I’ve the following problem: I’ve an app with a UITableView as root view. In

  • 0

I’ve the following problem:

I’ve an app with a UITableView as root view. In this tableView are different entries and for each entry (which can be created by the user) I also add a persistentstore to my app.

So, when I start the app from scratch (no saved data etc.) and add an entry, the persistentStore is also created and when I click on the tableViewCell, I can save Data in this generated persistentStore. This works fine if I’m creating an entry and also watch the entry during one single run.

BUT

If I close the app and start again, click on the same entry, I get the following error message:

NSFetchRequest *allUsers = [[NSFetchRequest alloc] init];
[allUsers setAffectedStores:[NSArray arrayWithObject:[[self.tableViewContext persistentStoreCoordinator] persistentStoreForURL:storeURL]]];

* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘* -[NSArray initWithObjects:count:]: attempt to insert nil object at objects[0]’

So it seems that I want to add a store which is actually nil, because (I guess so) the system can not find any store under this given storeURL (which is the same as the one where I created a store in the first run).

So I guess the persistentStore isn’t there in the second run, so it isn’t saved properly in the first run where it was created.

So how can I save a persistentStore, after I’ve added it, to the persistentStoreCoordinator?

Update:

I think I’ve identified the main problem. The persistentStoreCoordinator has changed after the first run. So how do I save all these things (managedObjectContext, persistentStoreCoordinator) before closing the app?

Can somebody help me?

Update 2

Here is how I create the store:

    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentPath = [searchPaths objectAtIndex:0];
    NSString* storeFileName = [NSString stringWithFormat:@"%@",newItem.name];
    NSURL *storeURL = [NSURL fileURLWithPath:[documentPath stringByAppendingPathComponent:storeFileName]];                            
     NSError* saveToStoreError;
    if(![[self.addContext persistentStoreCoordinator] addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&saveToStoreError]){
     NSLog(@"Error: %@, %@", saveToStoreError, [saveToStoreError userInfo]);
     abort();
    }
    else
    {
      NSError *saveStoreError;
      if(![self.addContext save:&saveStoreError])
      {
           NSLog(@"Saving Data wasn't possible!");
      }
    }

Update 3
So, after a lot of testing here are my results:

  • Creation of the stores works fine. I can create multiple stores and I can access and populate them as long as I’m in a single run of my app.

So something is changing with a restart of my app. I think the error must be associated with the managedObjectContext, the persistentStoreCoordinator or the SAVING of the stores.

Should I change any settings in my app delegate for setting up the managedObjectContext or the persistentStoreCoordinator?

Thanks!

  • 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-05-25T11:17:06+00:00Added an answer on May 25, 2026 at 11:17 am

    It was simply easy.

    I didn’t set addPersistentStoreWithType after restart in a view where I tried to fetch data from this store.

    Sorry for this post. Simply easy 😉 bangingmyheadonthewall

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

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.