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 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 have an app that is using itunes file sharing.I use these file to
My app is using iTunes file sharing which exposes everything in the Documents directory
Until now it was possible to import data into an iPhone app using iTunes
I currently have my app configured for file sharing through itunes. However, I want
I imported pdf file to iphone device using iTunes. I verified that the pdf
I just submitted my iPhone application using iTunes Connect, but I don't see anywhere
I'm using Apple's EPFImporter tool http://www.apple.com/itunes/affiliates/resources/documentation/epfimporter.html It's a Python script that will take space
I need to get access to the iTunes tags in an RSS feed using
I have a question about my app submission to itunes. My app using 256
I am developing iPad app which reads data (around 5000 rows) from sqlite and

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.