objective c - Failure to write NSString to file on iPad -


I am using a text file to save changes made by a user (the reason is that I am doing this because I can upload a text file later on the PC, and put it in an Excel spreadsheet from there. I have 3 data structures: a NSMutableArray key, and a NSMutableDictionary which is the key value of MSMutableArrays's NSStrings.

I repeat through these data structures and a file string compilation that looks like this:

  (key); (Value) \ t (value) \ t (value): \ n (key); (Value) .. so for now  

So, on the original question: when I try to save it, it fails. I am 99% sure that this is due to the path of the file I am using, but I have to see that to see the backup. The code is as follows:

  NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString * filePath = [Path ObjectAddIndex: 0]; NSString * file string = [NSString stringWithString: [tofileString]]; If (! [FileString writeToFile: file path atom: yes encoding: NSUTF8 string encoding error: NULL]) {NSLog (@ "Save file failed"); } Else {// do stuff}  

(The above code has been copied again because the actual code is on another computer. It compiles, so avoid spelling errors. Can I?)

I tried to use NSError, but I got stuck in the documentation and I thought how I could use the NSERR properly (a little stupid, sorry ).

99% sure it is the line of NSArray * path that is tripping it, but I do not know how to get a document directory.

Edit: The problem has been solved, and one last question: if I save it to the application's document directory, to see if it has been saved properly, close the app Where can I go? If it works like I think it does, then is not this a sandbox with the app's setting on the simulator? (I.e. there is no way to check it)

NSLog () I think you file yourself Trying to write in, not for the file.

Try it instead:

  filepath = [[paths objectAtIndex: 0] stringByAppendingPathComponent: @ "myfile.txt"];  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -