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

  • SEARCH
  • Home
  • 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 3785986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:36:46+00:00 2026-05-19T11:36:46+00:00

I just started with iPhone development. In one of the example where I had

  • 0

I just started with iPhone development. In one of the example where I had to display some data stored in sqlite db in a table view in a tabbar controller, I had to move a sqlite file from application bundle to the documents folder.

I used the application template – iOS > Application > Window-based application for iPhone (Used core data for storage)

In the template generated by XCode (base sdk set to latest iOS = 4.2), the following code was there…

- (NSURL *)applicationDocumentsDirectory {
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

In trying to get a path to documents folder, I used the method given above like this…

NSString *documentDirectory = [self applicationDocumentsDirectory];

This gave a warning – warning: incompatible Objective-C types initializing 'struct NSURL *', expected 'struct NSString *'

So I changed the code to following…

// Added the message absoluteString over here
NSString *documentDirectory = [[self applicationDocumentsDirectory] absoluteString];

NSString *writableDBPath = [documentDirectory stringByAppendingPathComponent:@"mydb.sqlite"];
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"mydb.sqlite"];
BOOL success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
   NSLog(@"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}

And BOOM!!! It gave the error that – 'Failed to create writable database file with message 'The operation couldn’t be completed. No such file or directory'.'

How should I find the path to documents directory since the method applicationDocumentsDirectory generated by XCode template does not work for me.

Also, can somebody throw some light on the purpose of applicationDocumentsDirectory method given above.

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-19T11:36:46+00:00Added an answer on May 19, 2026 at 11:36 am

    I just ran into this myself a few days ago. Don’t force things down the Path path, embrace the NSURL path. It won’t take but a short time to get how to use them.

    As to the method, it’s simply asking the system to hand you a URL to the standardized documents directory for the application. Use this and most everything regarding where you put new files will be correct.

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

Sidebar

Related Questions

I am just getting started with iphone development I have a Tabbed application and
I started using Core Data for iPhone development. I started out by creating a
I just started getting into iPhone development. I have been mish-mashing tutorials and material
So I've just started digging into Objective-C, Cocoa, and iPhone development. I've ran into
I just started creating my data-access layer using LinqToSql. Everybody is talking about the
My company has recently started developing custom iPhone applications for various clients. One of
I starte iPhone Development five days ago. To learn some techniques I created a
A couple of weeks ago i have started my research in Iphone app development
Just getting started on iPhone dev today and have run through Apple's HelloWorld tutorial:
Just started getting a bunch of errors on our C# .Net app that seemed

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.