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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:09:14+00:00 2026-05-23T14:09:14+00:00

All, I have the following code in my project: – (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if

  • 0

All,

I have the following code in my project:

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
    if (__persistentStoreCoordinator != nil)
    {
        return __persistentStoreCoordinator;
    }
    NSError *error = nil;


    NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"My_Model.sqlite"];

    NSURL *storeURL = [NSURL fileURLWithPath:storePath];


    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
    {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }

    return __persistentStoreCoordinator;
}

- (NSString *)applicationDocumentsDirectory
{
    NSError *err = nil;
    return [NSString stringWithContentsOfURL:[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject] encoding:NSUTF8StringEncoding error:&err];
}

And I am receiving an error:

* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘* -[NSURL initFileURLWithPath:]: nil string parameter’

What I don’t understand is why this is returning s nil? I have referenced a book for this code and it seems to think it should work all ok. Any ideas?

Thanks in advance

Paul

  • 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-23T14:09:14+00:00Added an answer on May 23, 2026 at 2:09 pm

    Your -applicationDocumentsDirectory method looks very strange to me. Instead of returning the path of the documents dir, you try to actually return the contents of this directory (which is probably not possible to read, hence it will return nil).

    Try replacing the method with

    - (NSURL *)applicationDocumentsDirectory
    {
        return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
                                                       inDomains:NSUserDomainMask] lastObject];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code to zip all the files and then save it
I have the following code: // Obtain the string names of all the elements
I have the following code to assign a value to all the elements of
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor
I have the following code: http://www.project-vanquish.co.cc/gridtest/drag-grid.html The plan is to allow the user to
I have the following code in a project for the main navigation. It is
I have the following code in a WPF 4 project, linked to an imagebox.
I have the following code inside my asp.net-mvc project: private string GenerateEmail(RequestContext requestContext) {
I have the following code: Tag.find_all_by_company_id(4).each.collect{|tag| tag.name }.join(,) (Essentially I'm trying to build a
I have the following code: preg_match_all('/(.*) \((\d+)\) - ([\d\.\d]+)[,?]/U', E-Book What I Didn't Learn

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.