In my project I have a view where I write words in some textfield, when I press a button these string must be stored in a csv file as this example: (example with 5 textfield)
firststring#secondstring#thirdstring#fourthstring#fifthstring;
this is an example of the result that I want. How can I do?
Edited to add:
code for the string
NSMutableString *csvString = [NSMutableString stringWithString:textfield1.text];
[csvString appendString:@"#"];
[csvString appendString:textfield2.text];
[csvString appendString:@"#"];
[csvString appendString:dtextfield3.text];
[csvString appendString:@"#"];
[csvString appendString:textfield4.text];
[csvString appendString:@"#"];
[csvString appendString:textfield5.text];
[csvString appendString:@"#"];
[csvString appendString:textfield6.text];
[csvString appendString:@"#"];
[csvString appendString:textfield7.text];
[csvString appendString:@"#"];
if (uiswitch.on) { //switch
[csvString appendString:@"1"];
}
else [csvString appendString:@"0"];
[csvString appendString:@";"];
finally csvString
NSLog(@"string = %@", csvString);
is exactly my string
Per the NSString Class Reference the error parameter should be NULL not nil in the writeToFile method, if you do not want to capture error details.
NSString Class Reference
Check the return value of the writeToFile method, if it returns NO there was an error writing to the file or the encoding: