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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:41:56+00:00 2026-06-01T14:41:56+00:00

I have an app where I save data to a file before quitting (or

  • 0

I have an app where I save data to a file before quitting (or going to background) and that restores it reading from the file when restarting the app. The problem is that this works perfectly on the simulator, but doesn’t on a real device.
Here is the code I use to get the path (on applicationDidFinishLaunching):

NSString *path=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]stringByAppendingString:@"archive"];
NSLog(@"Reading from filePath:%@",path);
if ([[NSFileManager defaultManager]fileExistsAtPath:path])
{
    //Init data from file
}
else
{
    //Present the view where the users has to enter info for the first time (this is what always gets executed)
}

And this is the code that I use to save the data(on applicationDidEnterBackground):

NSString *path=[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]stringByAppendingString:@"archive"];
 NSLog(@"Reading from filePath:%@",path);
NSMutableData *data=[[NSMutableData alloc]init];
//Put info to save in data
[data writeToFile:path atomically:YES];

I’ve checked in the iphone’s console, and when loading the info It print’s a directory that looks normal(I don’t have the device here so I can’t post the exact directory) , and then I see a deny file-write-create error like this:

unknown sandboxd[1332] <Notice>: AppName(1328) deny file-write-create

When I have acces to the device again (tomorrow) I’ll update the post with the exact directory printed. Any Idea why this happens?

  • 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-06-01T14:41:57+00:00Added an answer on June 1, 2026 at 2:41 pm

    Try using stringByAppendingPathComponent instead of stringByAppendingString

    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"archive"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app uses XML to save user data to a file. I have just
My app is accessing data from a remote XML file. I have no issues
I am working on an app and i have to save some data in
I have an app that saves google map markers, I basically save the lat
I have a client app that needs to save a username/password for an SMTP
I have an asp.net app and I am trying to save a text file
I am trying to send data from an Android app to a PHP file
I'm using Core data on my app ok, i have a problem when saving
I have an app which saves its user data into a file in the
I have an app where users can select an Excel file, that excel file

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.