Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you want is Dave DeLong's <a href="https://github.com/davedelong/CHCSVParser" rel="nofollow">CHCSVParser</a> (which also supports writing to CSV)</p> <p>To give a proper answer you need to provide more information though.</p> <p>First of all the string you provided actually is no valid CSV. It does not use commas (the "C" in CSV) to delimiter row fields. And it is trailed by a semicolon, while CSV would expect a line feed.</p> <p>So to get proper CSV file output you'd do:</p> <pre><code>#import "CHCSVWriter.h" //... NSArray *fields = [NSArray arrayWithObjects:@"firststring", @"secondstring", @"thirdstring", @"fourthstring", @"fifthstring", nil]; CHCSVWriter *writer = [[CHCSVWriter alloc] initWithCSVFile:filePath atomic:YES]; [writer writeLineWithFields:fields]; [writer closeFile]; </code></pre> <p>Which would result in a proper CSV à la:</p> <pre><code>"firststring", "secondstring", "thirdstring", "fourthstring", "fifthstring" </code></pre> <p>or:</p> <pre><code>firststring,secondstring,thirdstring,fourthstring,fifthstring </code></pre> <p>depending on configuration.</p> <hr> <p>To get output matching your sample, however:</p> <pre><code>NSArray *fields = [NSArray arrayWithObjects:@"firststring", @"secondstring", @"thirdstring", @"fourthstring", @"fifthstring", nil]; NSString *outputString = [[[fields componentsJoinedByString:@"#"] appendString:@";\n"]]; [outputString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil]; </code></pre> <p>The latter is very error prone however. As soon as one of those strings contains "#", ";" or "\n".</p> <p>Also my snippets use hard-coded strings. You however would need to create IBOutlets for each text field and ask those text fields for their string values.</p> <p>Example:</p> <pre><code>NSString *myString = myUITextField.text; </code></pre> <p>on OSX (&lt;=10.6) you'd use:</p> <pre><code>NSString *myString = [myNSTextField stringValue]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload