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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:55:57+00:00 2026-05-17T02:55:57+00:00

I am using iTunes file sharing in my app, and need to put Core

  • 0

I am using iTunes file sharing in my app, and need to put Core Data’s sqlite database elsewhere so that users don’t fiddle with it. I have read a previous SO post regarding the best way to hide the sqlite file that Core Data uses.

There seems to be conflicting opinions regarding whether to put the database in Library/Preferences or in a directory called .data, but I think I agree the best approach is to use the .data directory.

There is currently an -applicationDocumentsDirectory method that was provided by the Core Data template code:

- (NSString *)applicationDocumentsDirectory {
    return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
}

I would like to implement a function called applicationHiddenDocumentsDirectory that will give me access to the “.data” subdirectory, but I don’t know enough about Objective-C or the Cocoa/Foundation frameworks to access the directory.

Could someone help me implement this method please?

Thanks!

==Rowan==

  • 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-17T02:55:57+00:00Added an answer on May 17, 2026 at 2:55 am

    how do you like this one? You have to add appropriate action if an error occurs.
    EDIT: I changed this so the database is saved in the library-directory, which is backed up by itunes and not visible to the user. This was suggested by Apple Q&A

    - (NSString *)applicationHiddenDocumentsDirectory {
        // NSString *path = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@".data"];
        NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
        NSString *path = [libraryPath stringByAppendingPathComponent:@"Private Documents"];
    
        BOOL isDirectory = NO;
        if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory]) {
            if (isDirectory)
                return path;
            else {
                // Handle error. ".data" is a file which should not be there...
                [NSException raise:@".data exists, and is a file" format:@"Path: %@", path];
                // NSError *error = nil;
                // if (![[NSFileManager defaultManager] removeItemAtPath:path error:&error]) {
                //     [NSException raise:@"could not remove file" format:@"Path: %@", path];
                // }
            }
        }
        NSError *error = nil;
        if (![[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error]) {
            // Handle error.
            [NSException raise:@"Failed creating directory" format:@"[%@], %@", path, error];
        }
        return path;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get access to the iTunes tags in an RSS feed using
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Have a look on following application http://itunes.apple.com/us/app/fatbooth/id372268904?mt=8 i think they are using the same
I am using in-app purchase for an iPhone app. I have a class that
I'm developing an iPad app that will be distributed in-house using the Enterprise Program
I'm using PowersHell to automate iTunes but find the error handling / waiting for
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I'm trying to read the iTunes XML file with PHP. I want to extract
I am using lxml to read through an xml file and change a few

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.