2

I think the error is with the path, but I got the code (slightly modified) off a tutorial online for a Mac App, and it worked fine. It wrote to client_state.xml (in the build folder). However on my iphone navigation based app, it compiles and runs fine. And if I NSLog the data or the document I get the corresponding information, I just can't find the .xml file anywhere.

//doc_client is a DDXMLDocument file from kissXML.  The XMLData message returns the NSData
//from the document
NSData *xmlD = [doc_client XMLData];
[xmlD writeToFile:@"client_state.xml" atomically:YES];
Ash Furrow
  • 12,391
  • 3
  • 57
  • 92
MrHappyAsthma
  • 6,332
  • 9
  • 48
  • 78

1 Answers1

6

The file path is relative to the current working directory of your app; if the application is sandboxed and the current directory is outside the app bundle, the writeToFile:atomically: method will fail.

Try providing an absolute path constructed dynamically based on the main bundle.

Community
  • 1
  • 1
Ash Furrow
  • 12,391
  • 3
  • 57
  • 92