views:

50

answers:

1

iPhone Application writes data to a text file, saves it on the Documnets folder. Great that works

If I place "£" in the string, or use [currencyStyle stringFromNumber] the text file will not be created.

The "£" and the [currencyStyle stringFromNumber] works if the information is printed to a "New View" page on the simulator, pound and all

Can someone please explain what's happening?

+1  A: 

Make sure you're writing your string to the text file with the proper encoding. If you use the -writeToFile:atomically:encoding:error: method of NSString, you should pass NSUTF8Encoding as the encoding argument. You should not use the deprecated -writeToFile:atomically: method.

Ben Gottlieb
//make a file name to write the data to using the documents directory: NSString *fileName = [NSString stringWithFormat:@"%@/textfile.txt", documentsDirectory]; NSString *content = [NSString stringWithFormat: //save content to the documents directory [content writeToFile:fileName atomically:NO encoding:NSStringEncodingConversionAllowLossy error:nil];
Harry
do you have any examples how to do this
Harry
I have since used NSUTF8Encoding and can now print the £,but it now has a symbol + the £. any ideas how to get rid of that symbol. Thanks for your suggestion
Harry
problem solved thanks
Harry