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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:07:43+00:00 2026-05-12T09:07:43+00:00

I seem to have stumbled over a problem regarding saving an xml file from

  • 0

I seem to have stumbled over a problem regarding saving an xml file from a string (this is done on the iPhone)
The file itself exists and included in the project (hence within the workspace), and all indications I get from the code snippet which follows passes without any errors on the emulator and fail on the iPhone (error 513), but in either case the file is not saved!

{
Hits = config->Hits;

NSString*   filenameStr = [m_FileName stringByAppendingFormat: @".xml" ]; 
NSString*   pData = [self getDataString];  // write xml format - checked out ok
NSError     *error;

/* option 2 - does not work as well
 NSBundle        *mainBundle = [NSBundle mainBundle];
 NSURL           *xmlURL = [NSURL fileURLWithPath:[mainBundle pathForResource: m_FileName ofType: @"xml"]];

 if(![pData writeToURL: xmlURL atomically: true encoding:NSUTF8StringEncoding error:&error]) 
 {
 NSLog(@"Houston - we have a problem %s@\n",[error localizedFailureReason]);
 return false;
 }
 */

if(![pData writeToFile: filenameStr atomically: FALSE encoding:NSUTF8StringEncoding error:&error]) 
{
    NSLog(@"Houston - we have a problem %s@\n",[error localizedFailureReason]);
    return false;
}
return true;

}

Any help would be appreciated,
-A

  • 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-12T09:07:44+00:00Added an answer on May 12, 2026 at 9:07 am

    You should not write to files included in the application package. On a real iPhone, you may be prevented from doing this because these files are digitally signed.

    Even if you can modify a packaged file, it is not a good place to store data. Re-installing the application from an App Store upgrade or an Xcode build will overwrite the file with the original.

    Instead, store your XML into the Documents directory. You can get the path like this:

    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
        NSUserDomainMask, YES); 
    NSString* documentsDirectory = [paths objectAtIndex:0];     
    NSString* leafname = [m_FileName stringByAppendingFormat: @".xml" ]; 
    NSString* filenameStr = [documentsDirectory
        stringByAppendingPathComponent:leafname];
    

    If your file needs some initial state that you don’t want to generate in your code, have your app check that it is present in the documents directory the first time it is needed and, if it is missing, copy it from the template in the package.

    An alternative to storing structured data is to use user defaults. For example:

    [[NSUserDefaults standardUserDefaults] setObject:foo forKey:FOO_KEY];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 213k
  • Answers 213k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is a limitation of Windows and there is currently… May 12, 2026 at 10:32 pm
  • Editorial Team
    Editorial Team added an answer Perhaps: ^[A-Za-z. /]+$ That matches uppercase A-Z, lowercase a-z, dot,… May 12, 2026 at 10:32 pm
  • Editorial Team
    Editorial Team added an answer For MS Access, you'll need the dialect from HXTT. You'll… May 12, 2026 at 10:32 pm

Related Questions

After using the ebay API recently, I was expecting it to be as simple
This is my first time using Stack Overflow, so if I've done something wrong
I seem to have stumbled across a really weird issue when posting a static
I am trying out SubSonic to see if it is viable to use on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.